logback - remapping a log level for a specific logger

前端 未结 2 1601
渐次进展
渐次进展 2021-01-12 03:44

I have a logback configuration that has an appender with a threshold filter:



        
2条回答
  •  爱一瞬间的悲伤
    2021-01-12 04:43

    I know this is an old question - but it is actually possible to do what the OP wants to do with a single SyslogAppender.

    If others are searching for an example of how to remap you can take a look at the org.springframework.boot.logging.logback.LevelRemappingAppender class. With that appender it is possible to both remap what appender is finally used for the log event, and it is also possible to remap the level that is used for the final log event - e.g. by changing a DEBUG level into an INFO level.

    Usage example in logback config file (taken from https://github.com/spring-projects/spring-boot/blob/master/spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml):

    
        
        org.springframework.boot
        
        INFO->DEBUG,ERROR->WARN
    
    
    
        
    
    

    Note that remapping to a specific destination logger can make it harder to find the source code of the original log event - so use it with care.

提交回复
热议问题