From 0f637fb72220b9f4f436229441568d02620b8027 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Thu, 26 Oct 2023 12:47:43 +0200 Subject: [PATCH] (logging) Better logging configurations --- .../src/main/resources/log4j2-prod.xml | 28 ++++++++ .../src/main/resources/log4j2-test.xml | 27 ++++++++ .../src/main/resources/log4j2.properties | 65 ------------------- docker-service-with-dist.gradle | 5 -- docker-service.gradle | 5 -- run/env/service.env | 2 + 6 files changed, 57 insertions(+), 75 deletions(-) create mode 100644 code/common/service/src/main/resources/log4j2-prod.xml create mode 100644 code/common/service/src/main/resources/log4j2-test.xml delete mode 100644 code/common/service/src/main/resources/log4j2.properties diff --git a/code/common/service/src/main/resources/log4j2-prod.xml b/code/common/service/src/main/resources/log4j2-prod.xml new file mode 100644 index 00000000..0db23ea0 --- /dev/null +++ b/code/common/service/src/main/resources/log4j2-prod.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + %-5level %d{yyyy-MM-dd HH:mm:ss,SSS} %-20t %-20c{1}: %msg{nolookups}%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/common/service/src/main/resources/log4j2-test.xml b/code/common/service/src/main/resources/log4j2-test.xml new file mode 100644 index 00000000..0bd49338 --- /dev/null +++ b/code/common/service/src/main/resources/log4j2-test.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + %-5level %d{yyyy-MM-dd HH:mm:ss,SSS} %-20t %-20c{1}: %msg{nolookups}%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/common/service/src/main/resources/log4j2.properties b/code/common/service/src/main/resources/log4j2.properties deleted file mode 100644 index 96c73ea0..00000000 --- a/code/common/service/src/main/resources/log4j2.properties +++ /dev/null @@ -1,65 +0,0 @@ -log4j2.isThreadContextMapInheritable=true -status = info -appender.console.type = Console -appender.console.name = LogToConsole -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = %d{HH:mm:ss,SSS} %style{%-8markerSimpleName}{FG_Cyan} %highlight{%-5level}{FATAL=red, ERROR=red, WARN=yellow} %-24t %-20c{1} -- %msg{nolookups}%n -appender.console.filter.process.type = MarkerFilter -appender.console.filter.process.onMismatch=ACCEPT -appender.console.filter.process.onMatch=DENY -appender.console.filter.process.marker=PROCESS -appender.console.filter.http.type = MarkerFilter -appender.console.filter.http.onMismatch=ACCEPT -appender.console.filter.http.onMatch=DENY -appender.console.filter.http.marker=HTTP -appender.processconsole.type = Console -appender.processconsole.name = ProcessLogToConsole -appender.processconsole.layout.type = PatternLayout -appender.processconsole.layout.pattern = %msg{nolookups}%n -appender.processconsole.filter.process.type = MarkerFilter -appender.processconsole.filter.process.onMismatch=DENY -appender.processconsole.filter.process.onMatch=ACCEPT -appender.processconsole.filter.process.marker=PROCESS -appender.rolling.type = RollingFile -appender.rolling.name = RollingFile -appender.rolling.fileName = /var/log/wmsa/wmsa-${sys:service-name}.log -appender.rolling.filePattern = /var/log/wmsa/wmsa-${sys:service-name}-log-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz -appender.rolling.layout.pattern = %-5level %d{yyyy-MM-dd HH:mm:ss,SSS} %-20t %-20c{1}: %msg{nolookups}%n -appender.rolling.layout.type = PatternLayout -appender.rolling.policies.type = Policies -appender.rolling.policies.size.type = SizeBasedTriggeringPolicy -appender.rolling.policies.size.size=10MB -appender.rolling.strategy.type = DefaultRolloverStrategy -appender.rolling.strategy.max = 10 -appender.rolling.filter.query.type = MarkerFilter -appender.rolling.filter.query.onMismatch=ACCEPT -appender.rolling.filter.query.onMatch=DENY -appender.rolling.filter.query.marker=QUERY -appender.rolling.filter.http.type = MarkerFilter -appender.rolling.filter.http.onMismatch=ACCEPT -appender.rolling.filter.http.onMatch=DENY -appender.rolling.filter.http.marker=HTTP -appender.rolling.filter.process.type = MarkerFilter -appender.rolling.filter.process.onMismatch=ACCEPT -appender.rolling.filter.process.onMatch=DENY -appender.rolling.filter.process.marker=PROCESS -appender.process.type = RollingFile -appender.process.name = ProcessFile -appender.process.fileName = /var/log/wmsa/process.log -appender.process.filePattern = /var/log/wmsa/process-log-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz -appender.process.layout.pattern = %msg{nolookups}%n -appender.process.layout.type = PatternLayout -appender.process.policies.type = Policies -appender.process.policies.size.type = SizeBasedTriggeringPolicy -appender.process.policies.size.size=10MB -appender.process.strategy.type = DefaultRolloverStrategy -appender.process.strategy.max = 10 -appender.process.filter.process.type = MarkerFilter -appender.process.filter.process.onMismatch=DENY -appender.process.filter.process.onMatch=ACCEPT -appender.process.filter.process.marker=PROCESS -rootLogger.level = info -rootLogger.appenderRef.console.ref = LogToConsole -rootLogger.appenderRef.processconsole.ref = ProcessLogToConsole -rootLogger.appenderRef.rolling.ref = RollingFile -rootLogger.appenderRef.process.ref = ProcessFile \ No newline at end of file diff --git a/docker-service-with-dist.gradle b/docker-service-with-dist.gradle index 9954b596..6e67ce0e 100644 --- a/docker-service-with-dist.gradle +++ b/docker-service-with-dist.gradle @@ -1,7 +1,5 @@ ext { dockerImage='openjdk:21-slim' - serviceJvmOpts='--enable-preview -ea ${wmsa_jvm_param} -Dservice-host=0.0.0.0 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false' - serviceToolOpts='--enable-preview -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5000' } tasks.register('dockerFile') { @@ -25,9 +23,6 @@ ADD index-construction-process.tar /dist RUN mkdir /wmsa -ENV JAVA_TOOL_OPTIONS="${serviceToolOpts}" -ENV JAVA_OPTS="${serviceJvmOpts} " - ENTRYPOINT WMSA_HOME=/wmsa /${application.applicationName}/bin/${application.applicationName} \${arg0} \${arg1} """ } diff --git a/docker-service.gradle b/docker-service.gradle index b51787e2..98d80b44 100644 --- a/docker-service.gradle +++ b/docker-service.gradle @@ -1,7 +1,5 @@ ext { dockerImage='openjdk:21-slim' - serviceJvmOpts='--enable-preview -ea ${wmsa_jvm_param} -Dservice-host=0.0.0.0 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false' - serviceToolOpts='--enable-preview -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5000' } tasks.register('dockerFile') { @@ -19,9 +17,6 @@ FROM ${dockerImage} ADD ${application.applicationName}.tar / RUN mkdir /wmsa -ENV JAVA_TOOL_OPTIONS="${serviceToolOpts}" -ENV JAVA_OPTS="${serviceJvmOpts} " - ENTRYPOINT WMSA_HOME=/wmsa /${application.applicationName}/bin/${application.applicationName} \${arg0} \${arg1} """ } diff --git a/run/env/service.env b/run/env/service.env index 54184bdd..fb14622f 100644 --- a/run/env/service.env +++ b/run/env/service.env @@ -1,4 +1,6 @@ WMSA_HOME=run/ +JAVA_OPTS="--enable-preview -ea -Dlog4j2.configurationFile=log4j2-test.xml -Dservice-host=0.0.0.0 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" +JAVA_TOOL_OPTIONS="--enable-preview -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5000" EXECUTOR_SERVICE_OPTS="-DdistPath=/dist" CONVERTER_PROCESS_OPTS="-Dservice-host=0.0.0.0" CRAWLER_PROCESS_OPTS="-Dservice-host=0.0.0.0"