spring+slf4j+logback logback-spring.xml文件

参考链接:https://blog.csdn.net/xu_san_duo/article/details/80364600

1、修改application.properties新增:logging.config=classpath:logback-spring.xml
2、在resources目录下新建logback-spring.xml文件,内容如下:







    log_test
    
    
    
    
    
    
    

    
    
    
    
    
    
    

    
    
        
        
            debug
        
        
            ${CONSOLE_LOG_PATTERN}
            
            UTF-8
        
    

    
    
    
        
        ${log.path}/${log.project}_debug.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            UTF-8 
        
        
        
            
            ${log.path}/${log.project}_debug-%d{yyyy-MM-dd}.%i.log
            
                ${maxFileSize}
            
            
            ${maxHistory}
        
        
        
            debug
            ACCEPT
            DENY
        
    

    
    
        
        ${log.path}/${log.project}_info.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            UTF-8
        
        
        
            
            ${log.path}/${log.project}-info-%d{yyyy-MM-dd}.%i.log
            
                ${maxFileSize}
            
            
            ${maxHistory}
        
        
        
            info
            ACCEPT
            DENY
        
    

    
    
        
        ${log.path}/${log.project}_warn.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            UTF-8 
        
        
        
            ${log.path}/${log.project}-warn-%d{yyyy-MM-dd}.%i.log
            
                ${maxFileSize}
            
            
            ${maxHistory}
        
        
        
            warn
            ACCEPT
            DENY
        
    

    
    
        
        ${log.path}/${log.project}_error.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            UTF-8 
        
        
        
            ${log.path}/${log.project}-error-%d{yyyy-MM-dd}.%i.log
            
                ${maxFileSize}
            
            
            ${maxHistory}
        
        
        
            ERROR
            ACCEPT
            DENY
        
    
    
    
    
        
        
        
        
        
    
    
    
    
    
    
        
    
    
    
    


你可能感兴趣的:(spring+slf4j+logback logback-spring.xml文件)