Class Log4jWebConfigurer

  extended byorg.springframework.web.util.Log4jWebConfigurer

public abstract class Log4jWebConfigurer
extends java.lang.Object

Convenience class that performs custom Log4J initialization for web environments, supporting 2 init parameters at the servlet context level (i.e. context-param in web.xml):

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

Note: Sets the web app root system property, for "${key}" substitutions within log file locations in the Log4J config file. The default system property key is "webapp.root". Example, using context-param "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.

WARNING: The WAR file containing the web application needs to be expanded to allow for setting the web app root system property and for loading Log4J configuration from a custom location. This is by default not the case when a WAR file gets deployed to WebLogic, for example. Do not use this configurer respectively Log4jConfigListener or Log4jConfigServlet in such an environment!

Juergen Hoeller
See Also:
Log4jConfigurer, Log4jConfigListener, Log4jConfigServlet

Field Summary
static java.lang.String CONFIG_LOCATION_PARAM
          Parameter specifying the location of the Log4J config file
static java.lang.String REFRESH_INTERVAL_PARAM
          Parameter specifying the refresh interval for checking the Log4J config file
Constructor Summary
Method Summary
static void initLogging(javax.servlet.ServletContext servletContext)
static void shutdownLogging(javax.servlet.ServletContext servletContext)
          Shutdown Log4J to release all file locks.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final java.lang.String CONFIG_LOCATION_PARAM
Parameter specifying the location of the Log4J config file

See Also:
Constant Field Values


public static final java.lang.String REFRESH_INTERVAL_PARAM
Parameter specifying the refresh interval for checking the Log4J config file

See Also:
Constant Field Values
Constructor Detail


public Log4jWebConfigurer()
Method Detail


public static void initLogging(javax.servlet.ServletContext servletContext)


public static void shutdownLogging(javax.servlet.ServletContext servletContext)
Shutdown Log4J to release all file locks.

Copyright (C) 2003-2004 The Spring Framework Project.