Class LoggingHandlerInterceptor

  • All Implemented Interfaces:
    org.springframework.web.servlet.AsyncHandlerInterceptor, org.springframework.web.servlet.HandlerInterceptor

    @Component
    public class LoggingHandlerInterceptor
    extends org.springframework.web.servlet.handler.HandlerInterceptorAdapter
    Adds request details to the mapped diagnostic context (MDC) so they can be logged.
    http://www.devgrok.com/2017/04/adding-mdc-headers-to-every-spring-mvc.html
    • Constructor Detail

      • LoggingHandlerInterceptor

        public LoggingHandlerInterceptor()
    • Method Detail

      • preHandle

        public boolean preHandle​(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 Object handler)
                          throws Exception
        Invokes LogAdapter. Unfortunately ONAP use different conventions for key naming.
        Specified by:
        preHandle in interface org.springframework.web.servlet.HandlerInterceptor
        Overrides:
        preHandle in class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
        Throws:
        Exception
      • afterCompletion

        public void afterCompletion​(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    Object handler,
                                    Exception ex)
                             throws Exception
        Specified by:
        afterCompletion in interface org.springframework.web.servlet.HandlerInterceptor
        Overrides:
        afterCompletion in class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
        Throws:
        Exception