How can I configure Logback to log different levels for a logger to different destinations?

前端 未结 12 1811
挽巷
挽巷 2020-11-28 18:37

How can I configure Logback to log different levels for a logger to different destinations?

For example, given the following Logback configuration, will Logback reco

12条回答
  •  悲&欢浪女
    2020-11-28 18:56

    No programming needed. configuration make your life easy.

    Below is the configuration which logs different level of logs to different files

    
    
    
        
            INFO
        
        
            
                %d{yyyy-MM-dd HH:mm:ss} %-5level - %msg%n
            
        
    
    
    
        ${DEV_HOME}/app-error.log
        
            
                %d{yyyy-MM-dd HH:mm:ss} %-5level - %msg%n
            
        
    
        
            
            ${DEV_HOME}/archived/app-error.%d{yyyy-MM-dd}.%i.log
            
            
                10MB
            
        
    
        
            ERROR
            
            ACCEPT
            DENY
        
    
    
        ${DEV_HOME}/app-info.log
        
            
                %d{yyyy-MM-dd HH:mm:ss} %-5level - %msg%n
            
        
    
        
            
            ${DEV_HOME}/archived/app-info.%d{yyyy-MM-dd}.%i.log
            
            
                10MB
            
        
    
    
        
            INFO
            
            ACCEPT
            DENY
        
    
    
    
    
        ${DEV_HOME}/app-debug.log
        
            
                %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
            
        
    
        
            
            ${DEV_HOME}/archived/app-debug.%d{yyyy-MM-dd}.%i.log
            
            
                10MB
            
        
    
        
            DEBUG
            
            ACCEPT
            DENY
        
    
    
    
        ${DEV_HOME}/app.log
        
            
                %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
            
        
    
        
            
            ${DEV_HOME}/archived/app.%d{yyyy-MM-dd}.%i.log
            
            
                10MB
            
        
    
    
    
        
        
        
        
    
    
    
        
    
    

提交回复
热议问题