logback: Two appenders, multiple loggers, different levels

前端 未结 6 857
小蘑菇
小蘑菇 2020-12-02 07:46

I want to have two log files in my application (Spring Integration), debug.log and main.log. I want to run main.log at an INFO level and debug.log at a DEBUG level. This i

6条回答
  •  萌比男神i
    2020-12-02 08:06

    You can also do this somewhat more simply if you are willing to inherit from the root logger, e.g. here we add an extra logger for errors, that logs to stderr. It's only enabled for particular loggers.

    
        
            System.out 
            
                %d %-5level [%thread] %logger{0}: %msg%n
            
        
        
            
                ERROR
            
    
            System.err
            
                %d %-5level [%thread] %logger{0}: %msg%n
            
        
        
            
        
    
            
        
            
        
    
    

提交回复
热议问题