In Spring Boot 2
application I have configured Log4j2
with JsonLayout
like below
....
<Appenders>
<Console name="ConsoleJSONAppender" target="SYSTEM_OUT">
<JsonLayout complete="false" compact="false">
</JsonLayout>
</Console>
</Appenders>
<Logger name="CONSOLE_JSON_APPENDER" level="INFO" additivity="false">
<AppenderRef ref="ConsoleJSONAppender" />
</Logger>
.....
and I got output like below
{
"timeMillis" : 1496306649058,
"thread" : "main",
"level" : "INFO",
"loggerName" : "ConsoleJSONAppender",
"message" : "Json Message",
"endOfBatch" : false,
"loggerFqcn" : "org.apache.logging.log4j.spi.AbstractLogger",
"threadId" : 1,
"threadPriority" : 5
}
Output is fine but I don't want attributes like "endofBatch", "threadPriority" and others but it is getting displayed in logs, how to avoid unwanted (default) attributes in JsonLayout
based logs .
If you want to log only level
and loggerName
than customize like below in your configuration file.
...
<PatternLayout>
<pattern>{"level":"%p","loggerName":"%c"}</pattern>
</PatternLayout>
...
The parameter are described at here . Find Patterns
at Pattern Layout
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.