title: How to log spring-webflux WebClient request + response details (bodies, headers, elasped_time)?
body: <p>Basically, I want to log a request/response informations in one log containing bodies/headers with a Spring <code>WebClient</code>.</p>
  
  <p>With Spring <code>RestTemplate</code> we can do it with a <code>ClientHttpRequestInterceptor</code>. I find about <code>ExchangeFilterFunction</code> for Spring <code>WebClient</code> but haven't managed to do something similar in a clean way. We can use this filter and log the request AND THEN the response but I need both on the same log trace.</p>
  
  <p>Moreover, I haven't managed to get the response body with <code>ExchangeFilterFunction.ofResponseProcessor</code> method.</p>
  
  <p>I expect a log like this (current implementation working with a ClientHttpRequestInterceptor) with all the informations I need:</p>
  
  <pre><code>{
      "@timestamp": "2019-05-14T07:11:29.089+00:00",
      "@version": "1",
      "message": "GET https://awebservice.com/api",
      "logger_name": "com.sample.config.resttemplate.LoggingRequestInterceptor",
      "thread_name": "http-nio-8080-exec-5",
      "level": "TRACE",
      "level_value": 5000,
      "traceId": "e65634ee6a7c92a7",
      "spanId": "7a4d2282dbaf7cd5",
      "spanExportable": "false",
      "X-Span-Export": "false",
      "X-B3-SpanId": "7a4d2282dbaf7cd5",
      "X-B3-ParentSpanId": "e65634ee6a7c92a7",
      "X-B3-TraceId": "e65634ee6a7c92a7",
      "parentId": "e65634ee6a7c92a7",
      "method": "GET",
      "uri": "https://awebservice.com/api",
      "body": "[Empty]",
      "elapsed_time": 959,
      "status_code": 200,
      "status_text": "OK",
      "content_type": "text/html",
      "response_body": "{"message": "Hello World!"}"
  }
  </code></pre>
  
  <p>Does anyone manage to do something like this with Spring WebClient ? Or how would one proceed to track request/reponses issue with a Spring WebClient ?</p>