Skip to content

Instantly share code, notes, and snippets.

@boudhayan-dev
Created May 1, 2021 18:32
Show Gist options
  • Save boudhayan-dev/fc172be7bfe29df3d1bde43f91d9d8c3 to your computer and use it in GitHub Desktop.
Save boudhayan-dev/fc172be7bfe29df3d1bde43f91d9d8c3 to your computer and use it in GitHub Desktop.
public class LogFilter implements Filter {
public static final Logger log = LoggerFactory.getLogger(LogFilter.class);
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
MDC.put("LOGID", UUID.randomUUID().toString());
log.info("Received HTTP request for API : {} ",req.getRequestURI());
chain.doFilter(request, response);
}
@Override
public void init(FilterConfig filterconfig) throws ServletException {
}
@Override
public void destroy() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment