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:
jakarta.servlet.Filter, Aware, BeanNameAware, DisposableBean, InitializingBean, EnvironmentAware, EnvironmentCapable, ServletContextAware
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:
-
Field Summary
Fields inherited from class AbstractRequestLoggingFilter
DEFAULT_AFTER_MESSAGE_PREFIX, DEFAULT_AFTER_MESSAGE_SUFFIX, DEFAULT_BEFORE_MESSAGE_PREFIX, DEFAULT_BEFORE_MESSAGE_SUFFIXFields inherited from class OncePerRequestFilter
ALREADY_FILTERED_SUFFIXFields inherited from class GenericFilterBean
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterRequest(jakarta.servlet.http.HttpServletRequest request, String message) Writes a log message after the request is processed.protected voidbeforeRequest(jakarta.servlet.http.HttpServletRequest request, String message) Writes a log message before the request is processed.protected booleanshouldLog(jakarta.servlet.http.HttpServletRequest request) Determine whether to call theAbstractRequestLoggingFilter.beforeRequest(HttpServletRequest, String)/AbstractRequestLoggingFilter.afterRequest(HttpServletRequest, String)methods for the current request, i.e.Methods inherited from class AbstractRequestLoggingFilter
createMessage, doFilterInternal, getHeaderPredicate, getMaxPayloadLength, getMessagePayload, getQueryParamPredicate, isIncludeClientInfo, isIncludeHeaders, isIncludePayload, isIncludeQueryString, setAfterMessagePrefix, setAfterMessageSuffix, setBeforeMessagePrefix, setBeforeMessageSuffix, setHeaderPredicate, setIncludeClientInfo, setIncludeHeaders, setIncludePayload, setIncludeQueryString, setMaxPayloadLength, setQueryParamPredicate, shouldNotFilterAsyncDispatchMethods inherited from class OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterErrorDispatchMethods inherited from class GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
Constructor Details
-
CommonsRequestLoggingFilter
public CommonsRequestLoggingFilter()
-
-
Method Details
-
shouldLog
protected boolean shouldLog(jakarta.servlet.http.HttpServletRequest request) Description copied from class:AbstractRequestLoggingFilterDetermine whether to call theAbstractRequestLoggingFilter.beforeRequest(HttpServletRequest, String)/AbstractRequestLoggingFilter.afterRequest(HttpServletRequest, 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:
shouldLogin classAbstractRequestLoggingFilter- Parameters:
request- current HTTP request- Returns:
trueif the before/after method should get called;falseotherwise
-
beforeRequest
Writes a log message before the request is processed.- Specified by:
beforeRequestin classAbstractRequestLoggingFilter- Parameters:
request- current HTTP requestmessage- the message to log
-
afterRequest
Writes a log message after the request is processed.- Specified by:
afterRequestin classAbstractRequestLoggingFilter- Parameters:
request- current HTTP requestmessage- the message to log
-