Class DiagnosticContextFilter
- java.lang.Object
-
- com.devonfw.module.logging.common.impl.DiagnosticContextFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
public class DiagnosticContextFilter extends Object implements javax.servlet.Filter
Request logging filter that adds the request log message to the SLF4j mapped diagnostic context (MDC) before the request is processed, removing it again after the request is processed.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCORRELATION_ID_HEADER_NAME_DEFAULTThe default value forsetCorrelationIdHttpHeaderName(String).private static StringCORRELATION_ID_HEADER_NAME_PARAMThe name of theinit parameterforsetCorrelationIdHttpHeaderName(String).private StringcorrelationIdHttpHeaderNameprivate DiagnosticContextFacadediagnosticContextFacadeprivate static org.slf4j.LoggerLOG
-
Constructor Summary
Constructors Constructor Description DiagnosticContextFilter()The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)voidinit(javax.servlet.FilterConfig config)private static StringnormalizeValue(String value)private voidsetCorrelationId(javax.servlet.ServletRequest request)voidsetCorrelationIdHttpHeaderName(String correlationIdHttpHeaderName)voidsetDiagnosticContextFacade(DiagnosticContextFacade diagnosticContextFacade)
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
CORRELATION_ID_HEADER_NAME_PARAM
private static final String CORRELATION_ID_HEADER_NAME_PARAM
The name of theinit parameterforsetCorrelationIdHttpHeaderName(String).- See Also:
- Constant Field Values
-
CORRELATION_ID_HEADER_NAME_DEFAULT
public static final String CORRELATION_ID_HEADER_NAME_DEFAULT
The default value forsetCorrelationIdHttpHeaderName(String).- See Also:
- Constant Field Values
-
correlationIdHttpHeaderName
private String correlationIdHttpHeaderName
- See Also:
setCorrelationIdHttpHeaderName(String)
-
diagnosticContextFacade
private DiagnosticContextFacade diagnosticContextFacade
-
-
Method Detail
-
setCorrelationIdHttpHeaderName
public void setCorrelationIdHttpHeaderName(String correlationIdHttpHeaderName)
- Parameters:
correlationIdHttpHeaderName- is the name of theHTTP headerfor thecorrelation ID.
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.servlet.Filter
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException- Specified by:
doFilterin interfacejavax.servlet.Filter- Throws:
IOExceptionjavax.servlet.ServletException
-
setCorrelationId
private void setCorrelationId(javax.servlet.ServletRequest request)
-
setDiagnosticContextFacade
@Inject public void setDiagnosticContextFacade(DiagnosticContextFacade diagnosticContextFacade)
- Parameters:
diagnosticContextFacade- the diagnosticContextFacade to set
-
init
public void init(javax.servlet.FilterConfig config) throws javax.servlet.ServletException- Specified by:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException
-
-