Class SLF4JMDCServletFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class SLF4JMDCServletFilter
    extends Object
    implements javax.servlet.Filter
    Servlet filter that sets some interesting MDC attributes as the request comes in and clears the MDC as the response is returned.
    • Field Detail

      • SERVER_ADDRESS_MDC_ATTRIBUTE

        @Nonnull
        @NotEmpty
        public static final String SERVER_ADDRESS_MDC_ATTRIBUTE
        MDC attribute name for host name of the server to which the current request was sent.
        See Also:
        Constant Field Values
      • SERVER_PORT_MDC_ATTRIBUTE

        @Nonnull
        @NotEmpty
        public static final String SERVER_PORT_MDC_ATTRIBUTE
        MDC attribute name for port number to which the current request was sent.
        See Also:
        Constant Field Values
      • createSession

        private boolean createSession
        Whether to create a session if it doesn't already exist.
    • Constructor Detail

      • SLF4JMDCServletFilter

        public SLF4JMDCServletFilter()
    • Method Detail

      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.servlet.ServletException
      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter