org.springframework.web.util
Class Log4jWebConfigurer


public abstract class Log4jWebConfigurer

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!

Author:
Juergen Hoeller
Since: 12.08.2003
See Also: Log4jConfigurer, Log4jConfigListener, Log4jConfigServlet

Field Summary
 final static StringCONFIG_LOCATION_PARAM
          Parameter specifying the location of the Log4J config file
 final static StringREFRESH_INTERVAL_PARAM
          Parameter specifying the refresh interval for checking the Log4J config file

Method Summary
 static voidinitLogging(ServletContext servletContext)
           
 static voidshutdownLogging(ServletContext servletContext)
          Shutdown Log4J to release all file locks.

Field Detail

CONFIG_LOCATION_PARAM

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

REFRESH_INTERVAL_PARAM

public final static String REFRESH_INTERVAL_PARAM
Parameter specifying the refresh interval for checking the Log4J config file
Method Detail

initLogging

public static void initLogging(ServletContext servletContext)

shutdownLogging

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

Association Links

to Class java.lang.String

Parameter specifying the location of the Log4J config file

to Class java.lang.String

Parameter specifying the refresh interval for checking the Log4J config file