Package org.apache.hadoop.lib.servlet
Class MDCFilter
java.lang.Object
org.apache.hadoop.lib.servlet.MDCFilter
- All Implemented Interfaces:
javax.servlet.Filter
Filter that sets request contextual information for the slf4j MDC.
It sets the following values:
- hostname: if the
HostnameFilteris present and configured before this filter - user: the
HttpServletRequest.getUserPrincipal().getName() - method: the HTTP method fo the request (GET, POST, ...)
- path: the path of the request URL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroys the filter.voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) Sets the slf4jMDCand delegates the request to the chain.voidinit(javax.servlet.FilterConfig config) Initializes the filter.
-
Constructor Details
-
MDCFilter
public MDCFilter()
-
-
Method Details
-
init
public void init(javax.servlet.FilterConfig config) throws javax.servlet.ServletException Initializes the filter.This implementation is a NOP.
- Specified by:
initin interfacejavax.servlet.Filter- Parameters:
config- filter configuration.- Throws:
javax.servlet.ServletException- thrown if the filter could not be initialized.
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException Sets the slf4jMDCand delegates the request to the chain.- Specified by:
doFilterin interfacejavax.servlet.Filter- Parameters:
request- servlet request.response- servlet response.chain- filter chain.- Throws:
IOException- thrown if an IO error occurs.javax.servlet.ServletException- thrown if a servlet error occurs.
-
destroy
public void destroy()Destroys the filter.This implementation is a NOP.
- Specified by:
destroyin interfacejavax.servlet.Filter
-