Logback to log different messages to two files

前端 未结 3 1145
半阙折子戏
半阙折子戏 2020-11-29 15:45

I am using logback/slf4j to do my logging. I want to parse my log file to analyze some data, so instead of parsing a great big file (mostly consisting of debug statements) I

3条回答
  •  时光说笑
    2020-11-29 15:53

    It's very possible to do something like this in logback. Here's an example configuration:

    
    
        
            logfile.log
            true
            
                %-4relative [%thread] %-5level %logger{35} - %msg %n
            
        
        
            analytics.log
            true
            
                %-4relative [%thread] %-5level %logger{35} - %msg %n
            
        
        
        
            
        
        
            
        
    
    

    Then you'd setup two separate loggers, one for everything and one to log analytics data like so:

    Logger analytics = LoggerFactory.getLogger("analytics");
    

提交回复
热议问题