`
happyqing
  • 浏览: 3212464 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

spring,log4j报错,WARN No appenders could be found for logger的解决方法

阅读更多

 

在spring的web项目中常常会在tomcat启动的时候出现这种提示:

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


log4j.properties 前面要写日志级别,不能只写后面的

log4j.rootLogger= info,stdout


网上有好多解决办法都不管用,这个提示应该是读入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之前,就可以解决这个问题了。 

<!-- 以下3项参数与log4j的配置相关 -->  
       
    <context-param>  
        <param-name>log4jConfigLocation</param-name>  
        <param-value>classpath:log4j.properties</param-value>  
    </context-param>  
       
    <context-param>  
        <param-name>log4jRefreshInterval</param-name>  
        <param-value>60000</param-value>  
    </context-param>  
    <listener>  
        <listener-class>  
            org.springframework.web.util.Log4jConfigListener   
        </listener-class>  
    </listener>  
<!-- end -->  
  
    <listener>  
        <listener-class>  
            org.springframework.web.context.ContextLoaderListener   
        </listener-class>  
    </listener>  

 

分享到:
评论

相关推荐

    log4j:WARN No appenders could be found for logger (org.springframework.context.s

    NULL 博文链接:https://wait7758521.iteye.com/blog/1933964

    log4j.properties

    解决警告:log4j:WARN No appenders could be found for logger (org.springframework.web.filter.CharacterEncodingFilter).

    log4j简单配置

    例如,在Spring框架的应用中,如果没有正确配置log4j,就可能出现“log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext)”这类警告信息。...

    Java记录文档

    当出现"log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)"这样的警告时,这意味着log4j没有找到任何日志输出目标。这通常是因为日志配置文件未被正确加载。解决...

    struts2驱动包

    log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. 2009-8-29 14:02:12 org.apache.catalina.core....

    tomcat排错经典案例之404.docx

    log4j:WARN No appenders could be found for logger (org.apache.mons.digester.Digester). log4j:WARN Please initialize the log4j system properly. 2009-11-06 21:39:17 org.apache.catalina.core....

Global site tag (gtag.js) - Google Analytics