OncePerRequestFilter can't get request header content before Controller method is called

66 views Asked by At

I want to log activities in spring boot enabled application. I want to log “Request info”, controller “method activity” and “Response Info” In order of time. I tried to use OncePerRequestFilter and found it great. But there is a problem. To log request header body info by calling request.getContentAsByteArray() it is available for after execution of filterChain.doFilter(request, response). It means that I can log request header body content after controller method is called!!!

  1. Log Request info
  2. Log controller method
  3. Log Request header body
  4. Log Response Info
  5. Log Response body

Step 2,3 should be swap. How? Thanks

0

There are 0 answers