org.apache.logging.log4j.web
Interface Log4jWebSupport


public interface Log4jWebSupport

Specifies an interface for setting and clearing a thread-bound LoggerContext in a Java EE web application. Also defines constants for context parameter and attribute names. In most cases you will never need to use this directly because the Log4j filter handles this task automatically. However, in async operations you should wrap code that executes in separate threads with setLoggerContext() and clearLoggerContext().

You can obtain the instance of this for your web application by retrieving the ServletContext attribute named org.apache.logging.log4j.core.web.Log4jWebSupport.INSTANCE. If needed, you can also obtain the LoggerContext instance for your web application by retrieving the ServletContext attribute named org.apache.logging.log4j.spi.LoggerContext.INSTANCE.


Field Summary
static String CONTEXT_ATTRIBUTE
          The attribute key for the ServletContext attribute that the LoggerContext is stored in.
static String IS_LOG4J_AUTO_INITIALIZATION_DISABLED
          The ServletContext parameter name for the flag that disables Log4j's auto-initialization in Servlet 3.0+ web applications.
static String IS_LOG4J_CONTEXT_SELECTOR_NAMED
          The ServletContext parameter name for the JNDI flag.
static String LOG4J_CONFIG_LOCATION
          The ServletContext parameter name for the location of the configuration.
static String LOG4J_CONTEXT_NAME
          The ServletContext parameter name for the name of the LoggerContext.
static String SUPPORT_ATTRIBUTE
          The attribute key for the ServletContext attribute that the singleton support instance is stored in.
 
Method Summary
 void clearLoggerContext()
          Clears the logger context set up in setLoggerContext().
 void setLoggerContext()
          Sets the logger context so that code executing afterwards can easily and quickly access loggers via LogManager.getLogger().
 void wrapExecution(Runnable runnable)
          Sets the logger context by calling setLoggerContext(), executes the runnable argument, then clears the logger context by calling clearLoggerContext().
 

Field Detail

LOG4J_CONTEXT_NAME

static final String LOG4J_CONTEXT_NAME
The ServletContext parameter name for the name of the LoggerContext.

See Also:
Constant Field Values

LOG4J_CONFIG_LOCATION

static final String LOG4J_CONFIG_LOCATION
The ServletContext parameter name for the location of the configuration.

See Also:
Constant Field Values

IS_LOG4J_CONTEXT_SELECTOR_NAMED

static final String IS_LOG4J_CONTEXT_SELECTOR_NAMED
The ServletContext parameter name for the JNDI flag.

See Also:
Constant Field Values

IS_LOG4J_AUTO_INITIALIZATION_DISABLED

static final String IS_LOG4J_AUTO_INITIALIZATION_DISABLED
The ServletContext parameter name for the flag that disables Log4j's auto-initialization in Servlet 3.0+ web applications. Set a context parameter with this name to "true" to disable auto-initialization.

See Also:
Constant Field Values

SUPPORT_ATTRIBUTE

static final String SUPPORT_ATTRIBUTE
The attribute key for the ServletContext attribute that the singleton support instance is stored in.


CONTEXT_ATTRIBUTE

static final String CONTEXT_ATTRIBUTE
The attribute key for the ServletContext attribute that the LoggerContext is stored in.

Method Detail

setLoggerContext

void setLoggerContext()
Sets the logger context so that code executing afterwards can easily and quickly access loggers via LogManager.getLogger().


clearLoggerContext

void clearLoggerContext()
Clears the logger context set up in setLoggerContext().


wrapExecution

void wrapExecution(Runnable runnable)
Sets the logger context by calling setLoggerContext(), executes the runnable argument, then clears the logger context by calling clearLoggerContext().

Parameters:
runnable - The runnable to execute wrapped with a configured logger context


Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.