Is it possible to let log4j output its logging in JSON format by only altering the log4j.properties.xml
configuration file?
I make use of an old application tha
this is official JSON layout
https://github.com/logstash/log4j-jsonevent-layout
1) Add maven dependency https://mvnrepository.com/artifact/net.logstash.log4j/jsonevent-layout
net.logstash.log4j
jsonevent-layout
1.7
2) Add configuration to your log4j.properties
file
log4j.rootCategory=WARN, RollingLog
log4j.appender.RollingLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RollingLog.Threshold=TRACE
log4j.appender.RollingLog.File=api.log
log4j.appender.RollingLog.DatePattern=.yyyy-MM-dd
log4j.appender.RollingLog.layout=net.logstash.log4j.JSONEventLayoutV1