7

I believe it is a standard to log request and response in order to track down any issues reported by users and also to integrate it with tools like Splunk.

I've found 2 approaches so far, but none of them is really solving this issue properly:

  1. https://stackoverflow.com/a/64217998/4950459
  2. https://stackoverflow.com/a/47931511/4950459

Someone even wrote it is against reactive stack: https://stackoverflow.com/a/45280764/4950459

So I have questions:

  1. Isn't there any recommended way of doing it by Spring team?
  2. If logging in webflux is against reactive stack then how should we actually log request/response?
  3. If Webflux is not a proper place to log request/response then where should we catch those information from? Nginx could possibly log it with a request id - but is it a proper way of solving this issue?
SliceOfPig
  • 123
  • 3
  • 10
  • I am not a spring-team member, however I am quite surprised that such basic topic has not be somehow clearly supported in official documentation of webflux - especially looking into countless questions of same type in SO and in general over internet; what I found "best" option for logging responses is from chapter 4.2 in https://www.baeldung.com/spring-log-webclient-calls, adding custom `LoggingHandler` directly into `HttpClient`; would be delighted to hear other opinions though :) – asceta Oct 26 '20 at 23:08
  • and my personal opinion on gateway (nginx) logging - assuming the "request ID" or other kind of "trace/span" is generated by the service - might be hard to correlate the log on nginx; also - nginx will not allow any easy obfuscation of sensitive data, like in example https://github.com/zalando/logbook offers – asceta Oct 26 '20 at 23:15
  • 2
    @asceta baeldung article is about logging webClient req&res. I meant req&res that comes directly to Webflux app. Not calls that Webflix make using webClient (although this is another issue). As far as I know nginx can generate a random UUID and add it as a new header to a request. Then in your application you can log this header too so you will have a correlation – SliceOfPig Oct 27 '20 at 22:24
  • 1
    @SliceOfPig Did you find anything? – Saif Nov 22 '21 at 10:42

0 Answers0