@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
AbstractSecurityContext<?> securityContext = Application.get().getSecurityContext();
Entity user = securityContext != null ? securityContext.getUser() : null;
if (user != null) {
// Add the user id to the mapped diagnostic context. May be shown using %X{userId} in the layout pattern.
MDC.put(USER_ID, user.getId());
}
// Add the session id to the mapped diagnostic context. May be shown using %X{sessionId} in the layout pattern.
MDC.put(SESSION_ID, request.getSession().getId());