• 解决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日志!

  • 相关阅读:
    tableView
    ios设计模式 设计一个应用程序 笔记
    Touching the Background to close the Keyboard
    fdfd
    fdffafadf
    Declaring the Action Method
    网易公开课IOS笔记 第二课
    getters and setters
    objective c
    Google编码规范 C++ Style Guide, JavaScript Style Guide, ObjectiveC Style Guide, and Python Style Guide
  • 原文地址:https://www.cnblogs.com/Im-Victor/p/10998220.html
Copyright © 2020-2023  润新知