log4j2 xml configuration - Log to file and console (with different levels)

前端 未结 5 1051
情深已故
情深已故 2020-12-24 10:58

I want to do two things:

  1. Log to console with a certain log-level
  2. Log to file with another log-level

Console logging seems to work just

5条回答
  •  星月不相逢
    2020-12-24 11:54

    Although Daker had put the corrected configuration file but he didn't explain it. I would like to add explanation here. As quoted in Log4j2 Documentation here, usage of tag was not required for the given requirement. Further when you should use tag? Read below explanation form the documentation,

    Perhaps it is desired to eliminate all the TRACE output from everything except com.foo.Bar. Simply changing the log level would not accomplish the task. Instead, the solution is to add a new logger definition to the configuration:

    
       
        
         
      
      ...
    
    

提交回复
热议问题