public class Log4jNestedDiagnosticContextInterceptor extends Object implements AsyncWebRequestInterceptor
NDC.push(String)
,
NDC.pop()
Modifier and Type | Field and Description |
---|---|
protected Logger |
log4jLogger
Logger available to subclasses
|
Constructor and Description |
---|
Log4jNestedDiagnosticContextInterceptor() |
Modifier and Type | Method and Description |
---|---|
void |
afterCompletion(WebRequest request,
Exception ex)
Removes the log message from the Log4J NDC after the request is processed.
|
void |
afterConcurrentHandlingStarted(WebRequest request)
Removes the log message from the Log4J NDC when the processing thread is
exited after the start of asynchronous request handling.
|
protected String |
getNestedDiagnosticContextMessage(WebRequest request)
Determine the message to be pushed onto the Log4J nested diagnostic context.
|
protected boolean |
isIncludeClientInfo()
Return whether or not the session id and user name should be included
in the log message.
|
void |
postHandle(WebRequest request,
ModelMap model)
Intercept the execution of a request handler after its successful
invocation, right before view rendering (if any).
|
void |
preHandle(WebRequest request)
Adds a message the Log4J NDC before the request is processed.
|
void |
setIncludeClientInfo(boolean includeClientInfo)
Set whether or not the session id and user name should be included
in the log message.
|
protected final Logger log4jLogger
public Log4jNestedDiagnosticContextInterceptor()
public void setIncludeClientInfo(boolean includeClientInfo)
protected boolean isIncludeClientInfo()
public void preHandle(WebRequest request) throws Exception
preHandle
in interface WebRequestInterceptor
request
- the current web requestException
- in case of errorsprotected String getNestedDiagnosticContextMessage(WebRequest request)
Default is the request object's getDescription
result.
request
- current HTTP requestWebRequest.getDescription(boolean)
,
isIncludeClientInfo()
public void postHandle(WebRequest request, ModelMap model) throws Exception
WebRequestInterceptor
Allows for modifying context resources after successful handler execution (for example, flushing a Hibernate Session).
postHandle
in interface WebRequestInterceptor
request
- the current web requestmodel
- the map of model objects that will be exposed to the view
(may be null
). Can be used to analyze the exposed model
and/or to add further model attributes, if desired.Exception
- in case of errorspublic void afterCompletion(WebRequest request, Exception ex) throws Exception
afterCompletion
in interface WebRequestInterceptor
request
- the current web requestex
- exception thrown on handler execution, if anyException
- in case of errorspublic void afterConcurrentHandlingStarted(WebRequest request)
afterConcurrentHandlingStarted
in interface AsyncWebRequestInterceptor
request
- the current request