java - Does log4j support JSON format? -


is possible let log4j output logging in json format altering log4j.properties.xml configuration file?
make use of old application uses log4j 1.2. see xml layout no json layout.

just use buildin patternlayout ok:

log4j.appender.stdout=org.apache.log4j.consoleappender log4j.appender.stdout.encoding=utf-8 log4j.appender.stdout.layout=org.apache.log4j.patternlayout log4j.appender.stdout.layout.conversionpattern={"debug_level":"%p","debug_timestamp":"%d{iso8601}","debug_thread":"%t","debug_file":"%f", "debug_line":"%l","debug_message":"%m"}%n 

will out put like:

{     "debug_level" : "info",     "debug_timestamp" : "2016-05-26 16:37:08,938",     "debug_thread" : "main",     "debug_file" : "testlogoutput.java",     "debug_line" : "316",     "debug_message" : "hello log message" } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -