zoukankan      html  css  js  c++  java
  • 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.



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

    Xml代码 复制代码 收藏代码
      1. <!-- 以下3项参数与log4j的配置相关 -->  
      2.        
      3.     <context-param>  
      4.         <param-name>log4jConfigLocation</param-name>  
      5.         <param-value>/WEB-INF/log4j.properties</param-value>  
      6.     </context-param>  
      7.        
      8.     <context-param>  
      9.         <param-name>log4jRefreshInterval</param-name>  
      10.         <param-value>60000</param-value>  
      11.     </context-param>  
      12.     <listener>  
      13.         <listener-class>  
      14.             org.springframework.web.util.Log4jConfigListener   
      15.         </listener-class>  
      16.     </listener>  
      17. <!-- end -->  
      18.   
      19.     <listener>  
      20.         <listener-class>  
      21.             org.springframework.web.context.ContextLoaderListener   
      22.         </listener-class>  
      23.     </listener>
  • 相关阅读:
    十三.基础邮件服务、parted分区工具、交换分区、链路聚合
    十二.虚拟Web主机
    十一.简单MariaDB数据库的管理
    十.iSCSI网络磁盘
    九.配置SMB共享(Samba共享)
    八.防火墙相关操作
    bzoj3132
    bzoj4753
    codeforces round #418 div 2
    ural1519
  • 原文地址:https://www.cnblogs.com/x38160/p/3205463.html
Copyright © 2011-2022 走看看