springboot集成logback

1、引入maven依赖

        
        
            ch.qos.logback
            logback-classic
            1.2.3
        

2、再resource下面新建一个文件名称为 logback-spring.xml




    
    

    
    
    
    

    

    
    
        
        ../logs/${module_name}-info.log
        true
        
            %d{yyyy-MM-dd HH:mm:ssS} %5p [%c]:%L-%m%n
            UTF-8
        
        false
        
            ../logs/${module_name}-%d{yyyy-MM-dd}.%i.log.gz
            
                100MB
            
            15
        
    


    
        ../logs/${module_name}-error.log
        true
        
            %d{yyyy-MM-dd HH:mm:ssS} %5p [%c]:%L-%m%n
            UTF-8
        
        false
        
            ../logs/${module_name}.%d{yyyy-MM-dd}.log.gz
            7
        
    


    




    
    
    
        
    

3、logback详解



 
    
    
    
        
        
        
            
            
            
            
            
            
            
            %d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) --- [%15.15(%thread)] %cyan(%-40.40(%logger{40})) : %msg%n
            
            UTF-8
        
    
 
    
    
    
    
    
        
        logs/project_info.log
        
        true
        
            ERROR
            DENY
            ACCEPT
        
        
        
            
            
            
            logs/project_info.%d.%i.log
            
            30
            
            20GB
            
            10MB
        
        
        
            
            %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level --- [%15.15(%thread)] %-40.40(%logger{40}) : %msg%n
            
            UTF-8
        
    
 
    
    
    
    
    
        
        logs/project_error.log
        
        true
        
        
            ERROR
        
        
        
            
            
            
            logs/project_error.%d.%i.log
            
            30
            
            20GB
            
            10MB
        
        
        
            
            %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level --- [%15.15(%thread)] %-40.40(%logger{40}) : %msg%n
            
            UTF-8
        
    
 
    
    
    
        
    
 
    
    
    
        
        
    
 
    
    
        
        
    
 
    
    
        
        
    
 

你可能感兴趣的:(spring,boot,logback,后端)