mybatis WARN No appenders could be found for logger的解决方法

log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).
log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.


网上有好多解决办法都不管用,这个提示应该是读入web应用程序的log4j.properties文件之前就报出来了。是在加载org.springframework.web.context.ContextLoader这个listener的时候没找到log4j的配置文件造成的。 

仔细查看web.xml发现在加载org.springframework.web.context.ContextLoader这个listener之后才加载org.springframework.web.util.Log4jConfigListener,把log4j的配置放到org.springframework.web.context.ContextLoader之前,就可以解决这个问题了



	
	
		log4jConfigLocation
		/WEB-INF/log4j.properties
	
	
	
		log4jRefreshInterval
		60000
	
	
		
			org.springframework.web.util.Log4jConfigListener
		
	


	
		
			org.springframework.web.context.ContextLoaderListener
		
	


你可能感兴趣的:(mybatis WARN No appenders could be found for logger的解决方法)