Does log4j support JSON format?

前端 未结 4 1282
鱼传尺愫
鱼传尺愫 2021-02-01 03:17

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

4条回答
  •  别那么骄傲
    2021-02-01 03:58

    I used logback.xml with below pattern

    
        
            
                {"level":"%p","timestamp":"%d{ISO8601}","thread":"%t","file":"%F", "line":"%L","message":"%m"}%n
            
        
    
    

    and it generates logs in json format. I am using log4j which comes with springboot dependencies.

    {"level":"INFO","timestamp":"2020-09-22 15:26:38,354","thread":"main","file":"StartupInfoLogger.java", "line":"55","correlationId":"","message":"Starting Application on XX with PID 88794 (/Users/Documents/target/classes started by xxx in /Users/Documents)"}
    

提交回复
热议问题