日志
This commit is contained in:
@@ -3,7 +3,9 @@ package sample;
|
||||
import com.sunyard.proto.Util;
|
||||
import com.sunyard.sge.database.*;
|
||||
import com.sunyard.sge.database.Consts;
|
||||
import com.sunyard.sge.log.LogFactory;
|
||||
import org.junit.Assert;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
@@ -13,16 +15,30 @@ public class Sample
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
||||
// 路径要以 / 或 \\ 结尾表示目录
|
||||
SydApi.SYD_SetLogConfig("./logs/", Consts.LogLevelDebug );
|
||||
|
||||
SydApi api = new SydApi4Database();
|
||||
Logger log = LogFactory.getLogger();
|
||||
log.info("start");
|
||||
|
||||
// 通常单例就够了
|
||||
SydApiBuilder builder = new SydApiBuilder(
|
||||
new String[]{ "192.168.0.200" },
|
||||
new int[]{ 8889 },
|
||||
10,
|
||||
15
|
||||
);
|
||||
|
||||
// 每个工作线程中调用
|
||||
SydApi api = builder.build();
|
||||
try {
|
||||
api = api.SYD_Connect_Ex(
|
||||
new String[]{ "192.168.0.200" },
|
||||
new int[]{ 8889 },
|
||||
10,
|
||||
15
|
||||
);
|
||||
// 不建议使用了
|
||||
// api = api.SYD_Connect_Ex(
|
||||
// new String[]{ "192.168.0.200" },
|
||||
// new int[]{ 8889 },
|
||||
// 10,
|
||||
// 15
|
||||
// );
|
||||
|
||||
|
||||
// 短数据加密解密
|
||||
@@ -54,6 +70,8 @@ public class Sample
|
||||
if ( null != api ) {
|
||||
api.SYD_Disconnect_Ex();
|
||||
}
|
||||
System.out.println("all over");
|
||||
log.info("all over");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.slf4j.Logger;
|
||||
public class LogTest {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Logger log = LogFactory.createLogger();
|
||||
Logger log = LogFactory.createLogger("./test-log/", 2);
|
||||
log.error("error");
|
||||
log.info("info");
|
||||
log.debug("debug");
|
||||
|
||||
Reference in New Issue
Block a user