org.springframework.web.filter
Class Log4jNestedDiagnosticContextFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
org.springframework.web.filter.AbstractRequestLoggingFilter
org.springframework.web.filter.Log4jNestedDiagnosticContextFilter
- All Implemented Interfaces:
- Filter, Aware, BeanNameAware, DisposableBean, InitializingBean, EnvironmentAware, ServletContextAware
public class Log4jNestedDiagnosticContextFilter
- extends AbstractRequestLoggingFilter
Request logging filter that adds the request log message to the Log4J
nested diagnostic context (NDC) before the request is processed,
removing it again after the request is processed.
- Since:
- 1.2.5
- Author:
- Juergen Hoeller, Rob Harrop
- See Also:
AbstractRequestLoggingFilter.setIncludeQueryString(boolean)
,
AbstractRequestLoggingFilter.setBeforeMessagePrefix(java.lang.String)
,
AbstractRequestLoggingFilter.setBeforeMessageSuffix(java.lang.String)
,
AbstractRequestLoggingFilter.setAfterMessagePrefix(java.lang.String)
,
AbstractRequestLoggingFilter.setAfterMessageSuffix(java.lang.String)
,
NDC.push(String)
,
NDC.pop()
Methods inherited from class org.springframework.web.filter.AbstractRequestLoggingFilter |
createMessage, doFilterInternal, getMaxPayloadLength, isIncludeClientInfo, isIncludePayload, isIncludeQueryString, setAfterMessagePrefix, setAfterMessageSuffix, setBeforeMessagePrefix, setBeforeMessageSuffix, setIncludeClientInfo, setIncludePayload, setIncludeQueryString, setMaxPayloadLength |
Methods inherited from class org.springframework.web.filter.GenericFilterBean |
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log4jLogger
protected final Logger log4jLogger
- Logger available to subclasses
Log4jNestedDiagnosticContextFilter
public Log4jNestedDiagnosticContextFilter()
beforeRequest
protected void beforeRequest(HttpServletRequest request,
String message)
- Logs the before-request message through Log4J and
adds a message the Log4J NDC before the request is processed.
- Specified by:
beforeRequest
in class AbstractRequestLoggingFilter
- Parameters:
request
- current HTTP requestmessage
- the message to log
getNestedDiagnosticContextMessage
protected String getNestedDiagnosticContextMessage(HttpServletRequest request)
- Determine the message to be pushed onto the Log4J nested diagnostic context.
Default is a plain request log message without prefix or suffix.
- Parameters:
request
- current HTTP request
- Returns:
- the message to be pushed onto the Log4J NDC
- See Also:
AbstractRequestLoggingFilter.createMessage(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.String)
afterRequest
protected void afterRequest(HttpServletRequest request,
String message)
- Removes the log message from the Log4J NDC after the request is processed
and logs the after-request message through Log4J.
- Specified by:
afterRequest
in class AbstractRequestLoggingFilter
- Parameters:
request
- current HTTP requestmessage
- the message to log