使用logback记录日志

1. Pom引用依赖

<dependency>

        <groupId>ch.qos.logbackgroupId>

        <artifactId>logback-classicartifactId>

        <version>1.2.11version>

     dependency>

2. logback.xml





    
    
        
            %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} [line:%line] - %msg%n
        
    
    
    
        UTF-8
        
                
                logs/log-%d{yyyy-MM-dd}.%i.log
				30
                1MB
                100KB
            
        
            %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} [line:%line] - %msg%n
        
        
            DEBUG
            ACCEPT
            ACCEPT
        

    

     
        UTF-8
        
                
                logs/log-%d{yyyy-MM-dd}.%i.log
				30
                1MB
                100KB
            
        
            %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} [line:%line] - %msg%n
        
        
            INFO
            ACCEPT
            ACCEPT
        

    	

    
        UTF-8
         
                
                logs/mylog-%d{yyyy-MM-dd}.%i.log
				30
                1MB
                100KB
            
        
            %d{HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
        
        
            ERROR
            ACCEPT
            ACCEPT
        
    

    


    
    

    
        
        
	 
        
    

详细可到以下链接下载

https://download.csdn.net/download/liuyuxuan2388/86543481

你可能感兴趣的:(logback,java,服务器)