(logging) Better logging configurations
This commit is contained in:
parent
ba48c8e25b
commit
0f637fb722
28
code/common/service/src/main/resources/log4j2-prod.xml
Normal file
28
code/common/service/src/main/resources/log4j2-prod.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<Configuration xmlns="http://logging.apache.org/log4j/2.0/config" >
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss,SSS} %style{%-8markerSimpleName}{FG_Cyan} %highlight{%-5level}{FATAL=red, ERROR=red, WARN=yellow} %-24t %-20c{1} -- %msg%n"/>
|
||||
<Filters>
|
||||
<MarkerFilter marker="QUERY" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
<MarkerFilter marker="HTTP" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</Filters>
|
||||
</Console>
|
||||
<RollingFile name="LogToFile" fileName="/var/log/wmsa/wmsa-${sys:service-name}-${env:WMSA_SERVICE_NODE:-0}.log" filePattern="/var/log/wmsa/wmsa-${sys:service-name}-${env:WMSA_SERVICE_NODE:-0}-log-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz"
|
||||
ignoreExceptions="false">
|
||||
<PatternLayout>
|
||||
<Pattern>%-5level %d{yyyy-MM-dd HH:mm:ss,SSS} %-20t %-20c{1}: %msg{nolookups}%n</Pattern>
|
||||
</PatternLayout>
|
||||
<SizeBasedTriggeringPolicy size="10MB" />
|
||||
<Filters>
|
||||
<MarkerFilter marker="QUERY" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
<MarkerFilter marker="HTTP" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</Filters>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console"/>
|
||||
<AppenderRef ref="LogToFile"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
27
code/common/service/src/main/resources/log4j2-test.xml
Normal file
27
code/common/service/src/main/resources/log4j2-test.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<Configuration xmlns="http://logging.apache.org/log4j/2.0/config" >
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss,SSS} %style{%-8markerSimpleName}{FG_Cyan} %highlight{%-5level}{FATAL=red, ERROR=red, WARN=yellow} %-24t %-20c{1} -- %msg%n"/>
|
||||
<Filters>
|
||||
<MarkerFilter marker="HTTP" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</Filters>
|
||||
</Console>
|
||||
<RollingFile name="LogToFile" fileName="/var/log/wmsa/wmsa-${sys:service-name}-${env:WMSA_SERVICE_NODE:-0}.log" filePattern="/var/log/wmsa/wmsa-${sys:service-name}-${env:WMSA_SERVICE_NODE:-0}-log-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz"
|
||||
ignoreExceptions="false">
|
||||
<PatternLayout>
|
||||
<Pattern>%-5level %d{yyyy-MM-dd HH:mm:ss,SSS} %-20t %-20c{1}: %msg{nolookups}%n</Pattern>
|
||||
</PatternLayout>
|
||||
<SizeBasedTriggeringPolicy size="10MB" />
|
||||
<Filters>
|
||||
<MarkerFilter marker="QUERY" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
<MarkerFilter marker="HTTP" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</Filters>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console"/>
|
||||
<AppenderRef ref="LogToFile"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
@ -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
|
@ -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}
|
||||
"""
|
||||
}
|
||||
|
@ -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}
|
||||
"""
|
||||
}
|
||||
|
2
run/env/service.env
vendored
2
run/env/service.env
vendored
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user