解决log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)警告信息的问题

spring项目经常在启动tomcat时报如下警告信息:

log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). 
log4j:WARN Please initialize the log4j system properly.

网上贴出了各种解决办法我试了一下都不管用,这个错误信息应该是在加载spring的contextLoader时没有找到log4j造成的,所以解决方案很简单,就是把spring的配置contextConfigLocation放在log4j配置之后就OK了!我给大家贴出图,就一目了然了:

<context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>

    <!-- 定义LOG4J监听器 -->
    <listener>
        <listener-class>
            org.springframework.web.util.Log4jConfigListener
        </listener-class>
    </listener>

=======================================================================================================


<!--配置Spring IoC-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

 

如果按照这个顺序配置web.xml的话,就不会有哪个警告提示了,而且可以看到完整的spring日志!

解决log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)警告信息的问题

解决log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)警告信息的问题

上一篇:AndroidStudio——Android SDK


下一篇:浅释Functor、Applicative与Monad