Created
April 17, 2018 17:36
-
-
Save chathurangat/668db6b87579a31f201f430270e2bb63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.springbootdev.examples.slf4j.mdc.springbootslf4jmdcsupport.filter; | |
import org.slf4j.MDC; | |
import org.springframework.stereotype.Component; | |
import javax.servlet.*; | |
import java.io.IOException; | |
@Component | |
public class MdcLogEnhancerFilter implements Filter { | |
@Override | |
public void destroy() { | |
} | |
@Override | |
public void init(FilterConfig filterConfig) throws ServletException { | |
} | |
@Override | |
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException | |
{ | |
MDC.put("userId", "www.SpringBootDev.com"); | |
filterChain.doFilter(servletRequest, servletResponse); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment