logback 配置

阅读更多
为了实现日志自动清理,所以使用了logback来代替log4j,话不多说,下面就是实现方式,是不是超级简单?

 

添加依赖包


org.slf4j
slf4j-api
1.7.5


ch.qos.logback
logback-core
1.0.11


ch.qos.logback
logback-classic
1.0.11
 配置logback.xml



	
	
	
	

	
	
		
			${consoleLayoutPattern}
		
	

	
	
		${LOG_HOME}/info.log
		
		
			INFO
			ACCEPT
			DENY
		
		
			${LOG_HOME}/info.%d{yyyy-MM-dd}.log
			
			
			30
		
		
			${fileLayoutPattern}
		
	

	
		${LOG_HOME}/error.log
		
		
			ERROR
			ACCEPT
			DENY
		
		
			${LOG_HOME}/error.%d{yyyy-MM-dd}.log
			
			
			30
		
		
			${fileLayoutPattern}
		
	


	
	
		
		
		
	
 
java代码
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {
     public static Logger log = LoggerFactory.getLogger(Main.class);

public static void main(String[] args) {
     log.info("哦了");
     log.error("额。。。。");
}

}
 

你可能感兴趣的:(logback)