|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.logging.log4j.web.WebLoggerContextUtils
public final class WebLoggerContextUtils
Convenience methods for retrieving the LoggerContext
associated with a
particular ServletContext. These methods are most particularly useful for asynchronous servlets where the
Thread Context ClassLoader (TCCL) is potentially different from the TCCL used by the
Servlet container that bootstrapped Log4j.
Method Summary | |
---|---|
static LoggerContext |
getRequiredWebLoggerContext(javax.servlet.ServletContext servletContext)
Finds the main LoggerContext configured for the given ServletContext. |
static javax.servlet.ServletContext |
getServletContext()
Gets the current ServletContext if it has already been assigned to a LoggerContext's external context. |
static org.apache.logging.log4j.web.Log4jWebLifeCycle |
getWebLifeCycle(javax.servlet.ServletContext servletContext)
Finds or initializes the Log4jWebLifeCycle singleton for the given
ServletContext. |
static LoggerContext |
getWebLoggerContext(javax.servlet.ServletContext servletContext)
Finds the main LoggerContext configured for the given ServletContext. |
static Runnable |
wrapExecutionContext(javax.servlet.ServletContext servletContext,
Runnable runnable)
Wraps a Runnable instance by setting its thread context LoggerContext
before execution and clearing it after execution. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static LoggerContext getWebLoggerContext(javax.servlet.ServletContext servletContext)
LoggerContext
configured for the given ServletContext.
servletContext
- the ServletContext to locate a LoggerContext for
public static LoggerContext getRequiredWebLoggerContext(javax.servlet.ServletContext servletContext)
LoggerContext
configured for the given ServletContext.
servletContext
- the ServletContext to locate a LoggerContext for
null
if none was set
IllegalStateException
- if no LoggerContext could be found on the given ServletContextpublic static org.apache.logging.log4j.web.Log4jWebLifeCycle getWebLifeCycle(javax.servlet.ServletContext servletContext)
Log4jWebLifeCycle
singleton for the given
ServletContext.
servletContext
- the ServletContext to get the Log4jWebLifeCycle for
public static Runnable wrapExecutionContext(javax.servlet.ServletContext servletContext, Runnable runnable)
LoggerContext
before execution and clearing it after execution.
servletContext
- the ServletContext to locate a LoggerContext forrunnable
- the Runnable to wrap execution for
public static javax.servlet.ServletContext getServletContext()
ServletContext
if it has already been assigned to a LoggerContext's external context.
null
if none could be found
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.