From 5f42ed082cbecb22ea190bb705fb12054e44dd8a Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Sat, 11 Jun 2022 05:34:40 +0800 Subject: [PATCH] support debug log and normal log --- build.gradle | 13 ++++++++++--- .../debugger/org/bdware/sc/debugger/DebugMain.java | 2 +- src/main/java/org/bdware/sc/ContractProcess.java | 2 +- src/main/resources/log4j.properties | 8 -------- src/main/resources/log4j2.debug.properties | 10 ++++++++++ src/main/resources/log4j2.properties | 11 +++-------- 6 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 src/main/resources/log4j.properties create mode 100644 src/main/resources/log4j2.debug.properties diff --git a/build.gradle b/build.gradle index a72d0dc..de29133 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group = "org.bdware.sc" -version = "1.5.7" +version = "1.6.0" repositories { mavenCentral() mavenLocal() @@ -58,7 +58,7 @@ jar { } from { // uncomment this when publish! - configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } + // configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } manifest { attributes 'Manifest-Version': project.version @@ -75,10 +75,17 @@ task copyLibs(type: Copy, dependsOn: ":common:jar") { from configurations.runtimeClasspath } -task copyJar(type: Copy, dependsOn: ":cp:jar") { +task copyJar(type: Copy, dependsOn: [":cp:jar",":copyLog4jProp"]) { into "./build/output/" from "./build/libs/$project.name-${version}.jar" rename { String fileName -> "yjs.jar" } + from "./src/main/resources/log4j2.debug.properties" + from "./src/main/resources/log4j2.properties" +} +task copyLog4jProp(type: Copy) { + into "./build/output/" + from "./src/main/resources/log4j2.debug.properties" + from "./src/main/resources/log4j2.properties" } task buildBundle(dependsOn: [":cp:copyLibs", ":cp:copyJar"]) { diff --git a/src/main/debugger/org/bdware/sc/debugger/DebugMain.java b/src/main/debugger/org/bdware/sc/debugger/DebugMain.java index 934aa88..1e5da88 100644 --- a/src/main/debugger/org/bdware/sc/debugger/DebugMain.java +++ b/src/main/debugger/org/bdware/sc/debugger/DebugMain.java @@ -63,7 +63,7 @@ public class DebugMain { = new ResultCallback() { @Override public void onResult(String str) { - LOGGER.info(str); + LOGGER.debug(str); } }; ContractProcess.instance.handler.setDBInfo(wrap("", config.dbPath), printCallback); diff --git a/src/main/java/org/bdware/sc/ContractProcess.java b/src/main/java/org/bdware/sc/ContractProcess.java index b8a67fc..f79a4e3 100644 --- a/src/main/java/org/bdware/sc/ContractProcess.java +++ b/src/main/java/org/bdware/sc/ContractProcess.java @@ -722,7 +722,7 @@ public class ContractProcess { arg = new JsonPrimitive(""); } onCreate.setArg(arg); - LOGGER.info("invoke onCreate, param:" + onCreate.getArg().toString()); + LOGGER.debug("invoke onCreate, param:" + onCreate.getArg().toString()); onCreate.setRequester(contract.getOwner()); if (contract.getDoipFlag() && null != contract.getDOI() && !contract.getDOI().isEmpty()) { onCreate.setRequesterDOI(contract.getDOI()); diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties deleted file mode 100644 index f2fb500..0000000 --- a/src/main/resources/log4j.properties +++ /dev/null @@ -1,8 +0,0 @@ -### 设置### -log4j.rootLogger = debug,stdout - -### 输出信息到控制抬 ### -log4j.appender.stdout = org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target = System.out -log4j.appender.stdout.layout = org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{HH:mm:ss.SSS} %m (%F:%L)[%M]%n \ No newline at end of file diff --git a/src/main/resources/log4j2.debug.properties b/src/main/resources/log4j2.debug.properties new file mode 100644 index 0000000..c1d5638 --- /dev/null +++ b/src/main/resources/log4j2.debug.properties @@ -0,0 +1,10 @@ +filter.threshold.type=ThresholdFilter +filter.threshold.level=all +appender.console.type=Console +appender.console.name=STDOUT +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%highlight{[%-5p] %d{HH:mm:ss.SSS} %m (%F:%L)[%M]%n}{FATAL=Bright Red,ERROR=Red,WARN=Yellow,INFO=Green,DEBUG=Blue,TRACE=White} + +rootLogger.level=all +rootLogger.appenderRef.stdout.ref=STDOUT +rootLogger.appenderRef.log.ref=log diff --git a/src/main/resources/log4j2.properties b/src/main/resources/log4j2.properties index 7cb02aa..9106a0c 100644 --- a/src/main/resources/log4j2.properties +++ b/src/main/resources/log4j2.properties @@ -1,15 +1,10 @@ filter.threshold.type=ThresholdFilter -filter.threshold.level=debug +filter.threshold.level=error appender.console.type=Console appender.console.name=STDOUT appender.console.layout.type=PatternLayout appender.console.layout.pattern=%highlight{[%-5p] %d{HH:mm:ss.SSS} %m (%F:%L)[%M]%n}{FATAL=Bright Red,ERROR=Red,WARN=Yellow,INFO=Green,DEBUG=Blue,TRACE=White} -appender.rolling.type=File -appender.rolling.name=log -appender.rolling.append=true -appender.rolling.fileName=./log/ct.log -appender.rolling.layout.type=PatternLayout -appender.rolling.layout.pattern=%d-%m%n -rootLogger.level=info + +rootLogger.level=error rootLogger.appenderRef.stdout.ref=STDOUT rootLogger.appenderRef.log.ref=log \ No newline at end of file