Skip to content

Instantly share code, notes, and snippets.

@yusufcakal
Last active January 22, 2020 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yusufcakal/be00dd4a49fc5e0a01d0a0d4469314a9 to your computer and use it in GitHub Desktop.
Save yusufcakal/be00dd4a49fc5e0a01d0a0d4469314a9 to your computer and use it in GitHub Desktop.
Gelen her request'e ait özel bir referans numarası ile log'un takip edilmesi
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss.SSS} %clr([%thread]){magenta} %yellow([%X{requestId}]) %highlight(%-5level) %cyan(%-40.40logger{40}) - %msg %n
@Component
public class Slf4jMDCFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws java.io.IOException, ServletException {
MDC.put("requestId", "Request ID: " + UUID.randomUUID().toString());
chain.doFilter(request, response);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment