Springboot + logback日志打印配置

1.在resouces下新建logback.xml文件


image.png







    

    logback
    
    

    
    
    
    
    
    

    


    
    
        
        

            info
        
        
            ${CONSOLE_LOG_PATTERN}
            
            UTF-8
        
    


    
    
    
        
        
        ${log.path}/debug/log_debug.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            UTF-8 
        
        

        
            
            
            
            ${log.path}/debug/log-debug-%d{yyyy-MM-dd_HH-mm}.%i.log
            
            
            100MB
            
            30
            
            20GB
        
        
        
            debug
            ACCEPT
            DENY
        
    

    
    
        
        ${log.path}/info/log_info.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            UTF-8
        
        
        
            
            
            
            ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log
            
            
            100MB
            
            30
            
            20GB
        
        
        
        
        
            info
            ACCEPT
            DENY
        
    

    
    
        
        ${log.path}/warn/log_warn.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            UTF-8 
        
        
        
            
            
            
            ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log
            
            
            100MB
            
            30
            
            20GB
        
        
        
            warn
            ACCEPT
            DENY
        
    


    
    
        
        ${log.path}/error/log_error.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            UTF-8 
        
        
        
            
            
            
            ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log
            
            
            100MB
            
            30
            
            20GB
        
        
        
            ERROR
            ACCEPT
            DENY
        
    

    
    
    
    
    
    
        
        
        
        
        
    

    
    
        
    

    
    
    
        

            
            
            
        
    
    
    
        
            
        
    


3.在application.yml 中配置环境

spring:
  profiles:
    active: dev

你可能感兴趣的:(Springboot + logback日志打印配置)