spring-boot配置log4j(gradle)

spring-boot默认使用logback作为日志框架
要配置log4j,要在各种starter中排除logging依赖 添加 log4j依赖
如:
compile ('org.springframework.boot:spring-boot-starter-web'){
exclude module: 'spring-boot-starter-logging'
}
compile ('org.springframework.boot:spring-boot-starter-data-redis'){
exclude module: 'spring-boot-starter-logging'
}
compile ('org.springframework.boot:spring-boot-starter-activemq'){
exclude module: 'spring-boot-starter-logging'
}

compile(
'org.springframework.boot:spring-boot-starter-log4j2:1.5.7.RELEASE',
)

然后在classspath中添加 log4j2.xml


	
		
			
		

		
		
		
		
			
				%d [%t] %-5p [%c] - %m%n  
			

			
			
				
				
			
		

		
		
			
			
			
				%d [%t] %-5p [%c] - %m%n  
			
			
				
				
			
		
	

	
		
			
		
		
			
			
		
	



你可能感兴趣的:(SpringBoot)