Aisce  
日历
<2025年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
统计
  • 随笔 - 1
  • 文章 - 0
  • 评论 - 0
  • 引用 - 0

导航

常用链接

留言簿

随笔分类

随笔档案

搜索

  •  

最新评论

 

2012年12月9日

在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>  

posted @ 2012-12-09 23:04 Aisce.lin 阅读(337) | 评论 (0)编辑 收藏
 
Copyright © Aisce.lin Powered by: 博客园 模板提供:沪江博客