The default Log4j2 configuration writes log output to 2 files:
Log file | Description |
app.log | The main application log with information about the startup/shutdown process and with information about errors. |
audit.log | The audit log containing the actions taken by the user for managing the configuration via the Admin application. |
The log output is formatted according to a conversion pattern defined using a PatternLayout (file name: log4j2-prod.xml):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <? xml version = "1.0" encoding = "UTF-8" ?> < Configuration monitorInterval = "60" schema = "Log4J-config.xsd" > < Properties > < Property name = "log-path" >logs</ Property > </ Properties > < Appenders > < RollingFile name = "App-Appender" fileName = "${log-path}/admin-ui.log" filePattern = "${log-path}/admin-ui-%d{yyyy-MM-dd}.log" > < PatternLayout > < pattern > [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n </ pattern > </ PatternLayout > < Policies > < TimeBasedTriggeringPolicy /> </ Policies > </ RollingFile > < RollingFile name = "Audit-Appender" fileName = "${log-path}/audit.log" filePattern = "${log-path}/audit-%d{yyyy-MM-dd}.log" > < PatternLayout > < pattern > [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%X{accountId}] [%X{sessionId}] [%X{remoteAddress}] - %msg%n </ pattern > </ PatternLayout > < Policies > < TimeBasedTriggeringPolicy /> </ Policies > </ RollingFile > </ Appenders > < Loggers > < Root level = "info" > < AppenderRef ref = "App-Appender" /> </ Root > <!-- define audit logger --> < Logger name = "AUDIT" additivity = "false" > < AppenderRef ref = "Audit-Appender" /> </ Logger > </ Loggers > </ Configuration > |
In addition to this, there are two more log4j2 configurations you can use. You can configure these using the logging.config property in the application properties.
Log output using a JSONLayout in the console (file name: log4j2-console-json.xml):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <? xml version = "1.0" encoding = "UTF-8" ?> < Configuration status = "WARN" > < Appenders > < Console name = "Console" target = "SYSTEM_OUT" follow = "true" > < JSONLayout stacktraceAsString = "true" compact = "true" eventEol = "true" properties = "true" /> </ Console > </ Appenders > < Loggers > < Logger name = "org.apache.catalina.startup.DigesterFactory" level = "error" /> < Logger name = "org.apache.catalina.util.LifecycleBase" level = "error" /> < Logger name = "org.apache.coyote.http11.Http11NioProtocol" level = "warn" /> < Logger name = "org.apache.sshd.common.util.SecurityUtils" level = "warn" /> < Logger name = "org.apache.tomcat.util.net.NioSelectorPool" level = "warn" /> < Logger name = "org.eclipse.jetty.util.component.AbstractLifeCycle" level = "error" /> < Logger name = "org.hibernate.validator.internal.util.Version" level = "warn" /> < Logger name = "org.springframework.boot.actuate.endpoint.jmx" level = "warn" /> < Root level = "info" > < AppenderRef ref = "Console" /> </ Root > </ Loggers > </ Configuration > |
Log output in the console regularly (file name: log4j2-console.xml):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <? xml version = "1.0" encoding = "UTF-8" ?> < Configuration status = "WARN" > < Properties > < Property name = "LOG_PATTERN" >%d{yyyy-MM-dd HH:mm:ss.SSS} %5p %pid --- [%t] %-40.40c{1.} : %m%n%xwEx</ Property > </ Properties > < Appenders > < Console name = "Console" target = "SYSTEM_OUT" follow = "true" > < PatternLayout pattern = "${sys:LOG_PATTERN}" /> </ Console > </ Appenders > < Loggers > < Logger name = "org.apache.catalina.startup.DigesterFactory" level = "error" /> < Logger name = "org.apache.catalina.util.LifecycleBase" level = "error" /> < Logger name = "org.apache.coyote.http11.Http11NioProtocol" level = "warn" /> < Logger name = "org.apache.sshd.common.util.SecurityUtils" level = "warn" /> < Logger name = "org.apache.tomcat.util.net.NioSelectorPool" level = "warn" /> < Logger name = "org.eclipse.jetty.util.component.AbstractLifeCycle" level = "error" /> < Logger name = "org.hibernate.validator.internal.util.Version" level = "warn" /> < Logger name = "org.springframework.boot.actuate.endpoint.jmx" level = "warn" /> < Root level = "info" > < AppenderRef ref = "Console" /> </ Root > </ Loggers > </ Configuration > |
The 3DS Admin application uses Mapped Diagnostic Context (MDC) to expose additional information available for log output.
Exposed info is the logged user Account ID
, the logged user Session ID
and the logged user remote address
.
You can use information exposed via MDC in your log output by using the following conversion pattern:
%X{accountId}
%X{sessionId}
%X{remoteAddress}
For more details about conversion patterns please refer to the Log4j PatternLayout documentation.
Although not recommended, you can use your own Log4j configuration.
To do so, you have to override the logging.config
property in 3DS Admin Configuration Properties which specifies the location of the log4j configuration.