title: Java Spring Boot - logging response with payloads
body: <p>I'm currently integrating request / response logging into a REST service using Spring Boot. For requests, I chose the CommonsRequestLoggingFilter as provided by Spring:</p>
  
  <pre><code>@Bean
  public CommonsRequestLoggingFilter requestLoggingFilter() {
      CommonsRequestLoggingFilter loggingFilter = new CommonsRequestLoggingFilter();
      loggingFilter.setIncludeClientInfo(false);
      loggingFilter.setIncludeQueryString(true);
      loggingFilter.setIncludePayload(true);
      loggingFilter.setMaxPayloadLength(1024);
  
      return loggingFilter;
  }
  </code></pre>
  
  <p>And in the configuration file:</p>
  
  <pre><code>logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG
  </code></pre>
  
  <p>For reponses, however, there seems to be no corresponding class? Is there a similar way to log the server response in Spring?</p>
  
  <p>EDIT:
  Specically, what I see with the above setup is nothing in BeforeRequest:</p>
  
  <pre><code>2017-06-28 09:32:32.258 DEBUG 22872 --- [http-nio-8081-exec-2] o.s.w.f.CommonsRequestLoggingFilter      : Before request [uri=/someApp/someObject]
  </code></pre>
  
  <p>The request payload as AfterRequest:</p>
  
  <pre><code>2017-06-28 09:32:32.272 DEBUG 22872 --- [http-nio-8081-exec-2] o.s.w.f.CommonsRequestLoggingFilter      : 
  After request [uri=/someApp/someResource;payload={
    "someObject":   {
                      "lastName": "Doe",
                      "reference": "123456789"
                }
      }
  ]
  </code></pre>
  
  <p>And the actual response is nowhere in the log.</p>