Package-specific logging levels for different Logback appenders

前端 未结 1 564
再見小時候
再見小時候 2021-01-17 23:12

I have this simple Logback config file, containing two appenders and some custom logging levels based on package name.



        
1条回答
  •  星月不相逢
    2021-01-18 00:17

    If you don't want to implement a custom filter, you can create a new appender with a fixed threshold (in you case INFO):

    
        ...
        
            INFO
        
    
    

    Then, for your custom logging levels add the INFO_CONSOLE and your FILE appender. The additivity="false" attribute prevents the logger from logging to the CONSOLE appender inherited from root.

    
        
        
    
    

    This should log DEBUG and above to the FILE and CONSOLE appenders, except for myapp.package1 which will only log INFO and above to CONSOLE.

    0 讨论(0)
提交回复
热议问题