在spring的web项目中常常会在tomcat启动的时候出现这种提示:
这个提示应该是读入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之前,就可以解决这个问题了。
引用
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly
log4j:WARN Please initialize the log4j system properly
这个提示应该是读入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之前,就可以解决这个问题了。
本文介绍了解决Spring Web项目中启动Tomcat时出现的Log4j警告的方法。该警告源于ContextLoader监听器加载前未能正确初始化Log4j配置。通过调整web.xml中Log4jConfigListener与ContextLoader的加载顺序可以有效解决此问题。
7544

被折叠的 条评论
为什么被折叠?



