com.elasticpath.web.context.impl
Class EpLog4jConfigListener

java.lang.Object
  extended by com.elasticpath.web.context.impl.EpLog4jConfigListener
All Implemented Interfaces:
java.util.EventListener, javax.servlet.ServletContextListener

public class EpLog4jConfigListener
extends java.lang.Object
implements javax.servlet.ServletContextListener

EpLog4jConfigListener is the bootstrap listener for custom Log4J initialization in a web environment. WARNING: Assumes an expanded WAR file, both for loading the configuration file and for writing the log files.

This listener will expect and context parameter "log4jConfigLocation" for lo4j.properties file, relative the application root, i.e. "WEB-INF/conf/misc/log4j.properties". For any log file location specification inside log4j.properties, please make sure it is relative the application root as well.

This listener should be registered before ContextLoaderListener in web.xml, when using custom Log4J initialization.

For Servlet 2.2 containers and Servlet 2.3 ones that do not initalize listeners before servlets, use Log4jConfigServlet. See the ContextLoaderServlet javadoc for details.


Field Summary
static java.lang.String CONFIG_LOCATION_PARAM
          Parameter specifying the location of the Log4J config file.
static java.lang.String WEB_APP_ROOT_INDICATOR
          The web application root indicator string used in log4j.properties.
 
Constructor Summary
EpLog4jConfigListener()
           
 
Method Summary
 void contextDestroyed(javax.servlet.ServletContextEvent event)
          Shutdown log4j.
 void contextInitialized(javax.servlet.ServletContextEvent event)
          Configure log4j.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_LOCATION_PARAM

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

See Also:
Constant Field Values

WEB_APP_ROOT_INDICATOR

public static final java.lang.String WEB_APP_ROOT_INDICATOR
The web application root indicator string used in log4j.properties.

See Also:
Constant Field Values
Constructor Detail

EpLog4jConfigListener

public EpLog4jConfigListener()
Method Detail

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent event)
Shutdown log4j.

Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener
Parameters:
event - the servlet context event

contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent event)
Configure log4j.

Specified by:
contextInitialized in interface javax.servlet.ServletContextListener
Parameters:
event - the servlet context event