org.springframework.web.util.Log4jWebConfigurer

@Deprecated

Deprecated. as of Spring 4.2.1, in favor of Apache Log4j 2 (following Apache's EOL declaration for log4j 1.x)

Convenience class that performs custom log4j initialization for web environments, allowing for log file paths within the web application, with the option to perform automatic refresh checks (for runtime changes in logging configuration).

WARNING: Assumes an expanded WAR file, both for loading the configuration file and for writing the log files. If you want to keep your WAR unexpanded or don't need application-specific log files within the WAR directory, don't use log4j setup within the application (thus, don't use Log4jConfigListener or Log4jConfigServlet). Instead, use a global, VM-wide log4j setup (for example, in JBoss) or JDK 1.4's java.util.logging (which is global too).

Supports three init parameters at the servlet context level (that is, context-param entries in web.xml):
•"log4jConfigLocation":
Location of the log4j config file; either a "classpath:" location (e.g. "classpath:myLog4j.properties"), an absolute file URL (e.g. "file:C:/log4j.properties), or a plain path relative to the web application root directory (e.g. "/WEB-INF/log4j.properties"). If not specified, default log4j initialization will apply ("log4j.properties" or "log4j.xml" in the class path; see the log4j documentation for details).
•"log4jRefreshInterval":
Interval between config file refresh checks, in milliseconds. If not specified, no refresh checks will happen, which avoids starting log4j's watchdog thread.
•"log4jExposeWebAppRoot":
Whether the web app root system property should be exposed, allowing for log file paths relative to the web application root directory. Default is "true"; specify "false" to suppress expose of the web app root system property. See below for details on how to use this system property in log file locations.

Note: initLogging should be called before any other Spring activity (when using log4j), for proper initialization before any Spring logging attempts.

Log4j's watchdog thread will asynchronously check whether the timestamp of the config file has changed, using the given interval between checks. A refresh interval of 1000 milliseconds (one second), which allows to do on-demand log level changes with immediate effect, is not unfeasible.

WARNING: Log4j's watchdog thread does not terminate until VM shutdown; in particular, it does not terminate on LogManager shutdown. Therefore, it is recommended to not use config file refreshing in a production J2EE environment; the watchdog thread would not stop on application shutdown there.

By default, this configurer automatically sets the web app root system property, for "${key}" substitutions within log file locations in the log4j config file, allowing for log file paths relative to the web application root directory. The default system property key is "webapp.root", to be used in a log4j config file like as follows:

log4j.appender.myfile.File=${webapp.root}/WEB-INF/demo.log}

Alternatively, specify a unique context-param "webAppRootKey" per web application. For example, with "webAppRootKey = "demo.root":

log4j.appender.myfile.File=${demo.root}/WEB-INF/demo.log}

WARNING: Some containers (like Tomcat) do not keep system properties separate per web app. You have to use unique "webAppRootKey" context-params per web app then, to avoid clashes. Other containers like Resin do isolate each web app's system properties: Here you can use the default key (i.e. no "webAppRootKey" context-param at all) without worrying.

org.springframework.web.util.Log4jWebConfigurer的更多相关文章

  1. maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

    环境:Groovy/Grails Tool Suite 3.1.0.RELEASE(BASED ON ECLIPSE JUNO 3.8.1).JDK1.6.Maven3.05.Tomcat6 错误描述 ...

  2. maven web启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

    问题描述 SEVERE: Error configuring application listener of class org.springframework.web.util.Log4jConfi ...

  3. org.springframework.web.util.IntrospectorCleanupListener的用途

    Spring官方API中对其描述如下 /** * Listener that flushes the JDK's {@link java.beans.Introspector JavaBeans In ...

  4. org.springframework.web.util.NestedServletException : Handler processing failed; nested exception is java.lang.StackOverflowError

    1 ,错误原因,循环冗余检查      result.setNearUsers(userList);            Page page = new Page();            pag ...

  5. Spring MVC报异常:org.springframework.web.util.NestedServletException: Request processing failed

    在使用SpringMVC绑定基本类型(如String,Integer等)参数时,应通过@RequestParam注解指定具体的参数名称,否则,当源代码在非debug模式下编译后,运行时会引发Handl ...

  6. 解决java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

    启动eclipse 发现如下错误 Error configuring application listener of class org.springframework.web.util.Log4jC ...

  7. java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener

    一:如果出现下面的错误信息,如果你的项目是Maven结构的,那么一般都是你的项目的Maven Dependencies没有添加到项目的编译路径下: 信息: The APR based Apache T ...

  8. Maven项目Eclipse启动时报错: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener

    Eclipse中启动Maven项目时报如下错误: 严重: Error configuring application listener of class org.springframework.web ...

  9. gradle web项目启动报错: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener

    严重: Error configuring application listener of class org.springframework.web.util.IntrospectorCleanup ...

随机推荐

  1. 微信定时获取token

    为了使第三方开发者能够为用户提供更多更有价值的个性化服务,微信公众平台开放了许多接口,包括自定义菜单接口.客服接口.获取用户信息接口.用户分组接口.群发接口等,开发者在调用这些接口时,都需要传入一个相 ...

  2. python 基础回顾 一

    Python 基础回顾 可变类型:list ,dict 不可变类型:string,tuple,numbers tuple是不可变的,但是它包含的list dict是可变的. set 集合内部是唯一的 ...

  3. @Component单例与并发(未解决)

    今天用websocket记录连接的个数: 模拟少量请求到服务器端的websocket,@Component默认是单例的,让其注解到MyWebSocket类上: 每次请求过来都是相同的MyWebSock ...

  4. spring ContentNegotiationManagerFactoryBean 内容协商

    一.什么是内容协商 简单点说,就是同一资源,可以有多种表现形式,比如xml.json等,具体使用哪种表现形式,是可以协商的. 这是RESTfull的一个重要特性,Spring Web MVC也支持这个 ...

  5. EF CodeFirst学习笔记001--主键约定

    Code First 的核心是约定,这些默认的规则使我们可以用我们自己的类来创建模型.EF框架要求一个类必须有一个键属性.规则约定如果一个属性名为Id或者是类名+Id的形式(如PatientId),这 ...

  6. metasploit framework(十五):弱点扫描

    openvas扫描生成NBE格式的日志 改个比较好记的文件名 将日志导入到msf进行后续操作,导入之前查看一下hosts和services 导入nbe格式的文件 查看漏洞弱点 msf直接调用nessu ...

  7. DB2 57016报错的解决办法(表状态不正常,导致表无法操作)

    新建了一张表,删除了一列,然后执行insert的时候,报错 57016,解释为:因为表不活动. 1.执行db2 "load query table <tabname>" ...

  8. mysql 定时备份任务

    备份方案: 本地备份并同步至远程服务器,保留30天数据 1. 本地数据库备份,备份数据库gold_ecooy,naiang#!/bin/bash#xliang#Created Time: 2018-1 ...

  9. day31 粘包问题

    TCP粘包问题 cmd客户端代码 import socket import struct import socket import json c = socket.socket() c.connect ...

  10. Linux下鼠标滚轮速度调整

    安装imwheel 于home下创建.imwheelrc gedit ~/.imwheelrc 在.imwheelrc中粘贴以下内容 ".*" None, Up, Button4, ...