Apache logging services logo Apache log4j logo

Log4j Web

Contains classes that can be used to initialize logging within a web application.

Log4jContextListener

Log4j provides a ServletContextListener that will initialize the LoggerContext for your web application. It accepts two initialization parameters:

  1. log4jContextName - the name to be given to the LoggerContext. If not specified this will default to the display-name of the web application.
  2. log4jConfiguration - the location of the Log4j configuration file. If the file protocol is not specified then the file will be located both in the class path and on the file system. If the location is a relative path the file location will be relative to the current working directory of the running server.

JNDIContextFilter

The JNDIContextFilter is a Servlet Filter that can be used in conjunction with the JNDIContextSelector to identify the LoggerContext that should be used. It accepts two parameters.

  1. context-name - the name to be given to the LoggerContext. A context name must be specified.
  2. config-location - the location of the Log4j configuration file.

Requirements

The Log4j web components require at least Java 5.