com.interface21.web.util
Class Log4jConfigListener
java.lang.Object
|
+--com.interface21.web.util.Log4jConfigListener
- All Implemented Interfaces:
- java.util.EventListener, javax.servlet.ServletContextListener
- public class Log4jConfigListener
- extends java.lang.Object
- implements javax.servlet.ServletContextListener
Listener that performs custom Log4J initialization, supporting 2 init parameters
at the servlet context level (i.e. context-param in web.xml):
- "log4jLocation": name of the Log4J config file (relative to the web application
root directory, e.g. "WEB-INF/log4j.properties");
- "log4jRefreshInterval": interval between config file refresh* checks.
Note: This listener should be placed before ContextLoaderListener in web.xml,
at least when used for Log4J.
Note: Sets the web app root system property implicitly, 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.
- Since:
- 13.03.2003
- Author:
- Juergen Hoeller
- See Also:
Log4jConfigurer,
WebAppRootListener
|
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. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CONFIG_LOCATION_PARAM
public static final java.lang.String CONFIG_LOCATION_PARAM
- Parameter specifying the location of the Log4J config file.
REFRESH_INTERVAL_PARAM
public static final java.lang.String REFRESH_INTERVAL_PARAM
- Parameter specifying the refresh interval for checking the Log4J config file.
Log4jConfigListener
public Log4jConfigListener()
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent event)
- Specified by:
contextInitialized in interface javax.servlet.ServletContextListener
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent event)
- Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener
Rod Johnson and Spring contributors 2001-2003.