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.

时间: 2024-09-07 06:03:29

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

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 项目中启动报错jav

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

在使用SpringMVC绑定基本类型(如String,Integer等)参数时,应通过@RequestParam注解指定具体的参数名称,否则,当源代码在非debug模式下编译后,运行时会引发HandlerMethodInvocationException异常,这是因为只有在debug模式下编译,其参数名称才存储在编译好的代码中. 譬如下面的代码会引发异常: @RequestMapping(value = "/security/login", method = RequestMethod

Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupListener

I had a similar problem when running a spring web application in an Eclipse managed tomcat. I solved this problem by adding maven dependencies in the project's web deployment assembly. 找到解决方案: Open the project's properties (e.g., right-click on the p

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

Eclipse中启动Maven项目时报如下错误: 严重: Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupListener java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener at org.apache.catalina.lo

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

问题描述 SEVERE: Error configuring application listener of class org.springframework.web.util.Log4jConfigListener java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener 解决方案同 maven项目Tomcat controller 404

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

/** * org.springframework.web.util.IntrospectorCleanupListener的用途 * @see ------------------------------------------------------------------------------------------------------------------- * @see 此监听器出用于主要为了解决java.beans.Introspector导致内存泄漏的问题 * @see 此

org.springframework.web.util.IntrospectorCleanupListener

/** * org.springframework.web.util.IntrospectorCleanupListener的用途 * @see ------------------------------------------------------------------------------------------------------------------- * @see 此监听器出用于主要为了解决java.beans.Introspector导致内存泄漏的问题 * @see 此

idea 中 Caused by: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener

idea  中 Caused by: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener 项目启动出现未知错误: 代码未错,即为idea配置问题: 解決 在IDEA中点击File > Project Structure > Artifacts > 在右侧Output Layout右击项目名,选择Put into Output Root. ?执行后,在WEB-I

Error configuring application listener of class [org.springframework.web.util.Log4jConfigListener]

1.启动项目发现如下错误: 严重: Error configuring application listener of class [org.springframework.web.util.Log4jConfigListener] java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener at org.apache.catalina.loader.WebappClassLoaderBas