Package org.springframework.web.filter

# Class CommonsRequestLoggingFilter

java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
org.springframework.web.filter.AbstractRequestLoggingFilter
org.springframework.web.filter.CommonsRequestLoggingFilter

All Implemented Interfaces:
  `Filter`, `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.BeanNameAware`, `org.springframework.beans.factory.DisposableBean`, `org.springframework.beans.factory.InitializingBean`, `org.springframework.context.EnvironmentAware`, `org.springframework.core.env.EnvironmentCapable`, `ServletContextAware`

public class CommonsRequestLoggingFilter extends AbstractRequestLoggingFilter
Simple request logging filter that writes the request URI (and optionally the query string) to the Commons Log.

Since:
  1.2.5
Author:
  Rob Harrop, Juergen Hoeller
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)`
  - `Log.debug(Object)`

## Field Summary

### Fields inherited from class org.springframework.web.filter.AbstractRequestLoggingFilter

`DEFAULT_AFTER_MESSAGE_PREFIX, DEFAULT_AFTER_MESSAGE_SUFFIX, DEFAULT_BEFORE_MESSAGE_PREFIX, DEFAULT_BEFORE_MESSAGE_SUFFIX`

### Fields inherited from class org.springframework.web.filter.OncePerRequestFilter

`ALREADY_FILTERED_SUFFIX`

### Fields inherited from class org.springframework.web.filter.GenericFilterBean

`logger`

## Constructor Summary

Constructors
Constructor
Description
`CommonsRequestLoggingFilter()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`afterRequest(HttpServletRequest request, String message)`
Writes a log message after the request is processed.
`protected void`
`beforeRequest(HttpServletRequest request, String message)`
Writes a log message before the request is processed.
`protected boolean`
`shouldLog(HttpServletRequest request)`
Determine whether to call the `AbstractRequestLoggingFilter.beforeRequest(jakarta.servlet.http.HttpServletRequest, java.lang.String)`/`AbstractRequestLoggingFilter.afterRequest(jakarta.servlet.http.HttpServletRequest, java.lang.String)` methods for the current request, i.e.

### Methods inherited from class org.springframework.web.filter.AbstractRequestLoggingFilter

`createMessage, doFilterInternal, getHeaderPredicate, getMaxPayloadLength, getMessagePayload, isIncludeClientInfo, isIncludeHeaders, isIncludePayload, isIncludeQueryString, setAfterMessagePrefix, setAfterMessageSuffix, setBeforeMessagePrefix, setBeforeMessageSuffix, setHeaderPredicate, setIncludeClientInfo, setIncludeHeaders, setIncludePayload, setIncludeQueryString, setMaxPayloadLength, shouldNotFilterAsyncDispatch`

### Methods inherited from class org.springframework.web.filter.OncePerRequestFilter

`doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterErrorDispatch`

### Methods inherited from class org.springframework.web.filter.GenericFilterBean

`addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, 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`

## Constructor Details

### CommonsRequestLoggingFilter

public CommonsRequestLoggingFilter()

## Method Details

### shouldLog

protected boolean shouldLog(HttpServletRequest request)
Description copied from class: `AbstractRequestLoggingFilter`
Determine whether to call the `AbstractRequestLoggingFilter.beforeRequest(jakarta.servlet.http.HttpServletRequest, java.lang.String)`/`AbstractRequestLoggingFilter.afterRequest(jakarta.servlet.http.HttpServletRequest, java.lang.String)` methods for the current request, i.e. whether logging is currently active (and the log message is worth building).

The default implementation always returns `true`. Subclasses may override this with a log level check.

Overrides:
  `shouldLog` in class `AbstractRequestLoggingFilter`
Parameters:
  `request` - current HTTP request
Returns:
  `true` if the before/after method should get called; `false` otherwise

### beforeRequest

protected void beforeRequest(HttpServletRequest request, String message)
Writes a log message before the request is processed.

Specified by:
  `beforeRequest` in class `AbstractRequestLoggingFilter`
Parameters:
  `request` - current HTTP request
  `message` - the message to log

### afterRequest

protected void afterRequest(HttpServletRequest request, String message)
Writes a log message after the request is processed.

Specified by:
  `afterRequest` in class `AbstractRequestLoggingFilter`
Parameters:
  `request` - current HTTP request
  `message` - the message to log