public class

Log4jNestedDiagnosticContextFilter

extends AbstractRequestLoggingFilter
java.lang.Object
   ↳ org.springframework.web.filter.GenericFilterBean
     ↳ org.springframework.web.filter.OncePerRequestFilter
       ↳ org.springframework.web.filter.AbstractRequestLoggingFilter
         ↳ org.springframework.web.filter.Log4jNestedDiagnosticContextFilter

Class Overview

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.

Summary

[Expand]
Inherited Constants
From class org.springframework.web.filter.AbstractRequestLoggingFilter
From class org.springframework.web.filter.OncePerRequestFilter
Fields
protected final Logger log4jLogger Logger available to subclasses
[Expand]
Inherited Fields
From class org.springframework.web.filter.GenericFilterBean
Public Constructors
Log4jNestedDiagnosticContextFilter()
Protected Methods
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.
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.
String getNestedDiagnosticContextMessage(HttpServletRequest request)
Determine the message to be pushed onto the Log4J nested diagnostic context.
[Expand]
Inherited Methods
From class org.springframework.web.filter.AbstractRequestLoggingFilter
From class org.springframework.web.filter.OncePerRequestFilter
From class org.springframework.web.filter.GenericFilterBean
From class java.lang.Object
From interface javax.servlet.Filter
From interface org.springframework.beans.factory.BeanNameAware
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.context.EnvironmentAware
From interface org.springframework.web.context.ServletContextAware

Fields

protected final Logger log4jLogger

Logger available to subclasses

Public Constructors

public Log4jNestedDiagnosticContextFilter ()

Protected Methods

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.

Parameters
request current HTTP request
message the message to log

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.

Parameters
request current HTTP request
message the message to log

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