Spring监听器配置
使用spring框架时如果同时使用org.springframework.web.util.Log4jConfigListener监听器,那么在web.xml中的监听器的注册顺序为org.springframework.web.context.ContextLoaderListener在后,org.springframework.web.util.Log4jConfigListener在前,否则就回出现如下警告:
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
我们在spring的api文档中可以看到下面一段说明:
Bootstrap listener to start up Spring's root WebApplicationContext
. Simply delegates to ContextLoader
.
This listener should be registered after Log4jConfigListener
in web.xml
, if the latter is used.
正确配置如下:
<listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
作者: lost blog
出处: http://www.cnblogs.com/JAYIT/
关于作者:专注服务器端开发
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接 如有问题, 可邮件(sawyershaw@qq.com)咨询.