web.xml配置详解 org.springframework.web.util.Log4jConfigListener
来源:互联网 发布:java agentmain 编辑:程序博客网 时间:2024/05/22 23:59
在Web应用中利用Spring配置log4j
Spring提供了一个很实用的工具,可以让Web应用灵活配置log4j,这个工具类是:
org.springframework.web.util.Log4jConfigListener
org.springframework.web.util.Log4jConfigServlet
由于:
Note that this class has been deprecated for containers implementing
Servlet API 2.4 or higher, in favor ofLog4jConfigListener}.</i><br>
According to Servlet 2.4, listeners must be initialized before load-on-startup
servlets. Many Servlet 2.3 containers already enforce this behavior
(see ContextLoaderServlet javadocs for details). If you use such a container,
this servlet can be replaced with Log4jConfigListener.
建议使用org.springframework.web.util.Log4jConfigListener,而非org.springframework.web.util.Log4jConfigServlet,下面来说下Log4jConfigListener的用法:
其实很简单,只要在web.xml文件中配置相关参数和注册此监听器即可,下面是相应的配置片段:
<!-- 配置log4j配置文件的路径,可以是xml或 properties文件(此参数必须配)-->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF/log4j.properties</param-value>
</context-param>
<!-- 每隔多少毫秒扫描一下配置文件的变化(此参数可选配) -->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<!-- spring框架默认定义webAppRootKey的值为webapp.root,若不配此参数默认值就是webapp.root(因此,此参数可选配) -->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>home</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
了解更多请看下篇blog log4j.properties详解
- web.xml配置详解 org.springframework.web.util.Log4jConfigListener
- org.springframework.web.util.Log4jConfigListener
- java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- `java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener`
- 解决:java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- ava.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- Delphi中TFlowPanel实现滚动条效果
- ERP项目实施记录02
- TreeMap学习笔记:put方法
- 在Service中弹出AlertDialog
- Mysql group by top N的问题
- web.xml配置详解 org.springframework.web.util.Log4jConfigListener
- android读取图片及播放音频
- 自定义Checkbox的checked与unchecked
- 【分享】RSS订阅技巧及工具和实用RSS链接分享
- 聚焦等值面的创建
- 那些因为专注而成功的IT人
- LPC2478串口分频
- 将ios代码在后台(子线程)执行的两种简单方式
- 关于报错“syntax error near unexpected token `”和回车换行