I have a Spring Boot application, a reactive service which calls external systems via WebClient. I also have some non-reactive services. There is already implemented logging using MDC
+ Logbook
for Feign
clients. It's highly desirable to reuse existing classes or at least make log records look the same as non-reactive services logs.
RESPONSE_CODE=200, RESPONSE_HEADERS=[transfer-encoding:"chunked"], METHOD=POST, REQUEST_QUERY={}, REQUEST_BODY=FluxMap, RESPONSE_BODY=, REQUEST_PATH=/ping, REQUEST_HEADERS=[Session:"11111abcd", Content-Type:"application/json", ..., Content-Length:"37"], TYPE=INREQ
Current logs look like that. Problematic parts are REQUEST_BODY=FluxMap
and RESPONSE_BODY=
I managed to log body using wiretap()
on WebClient, but it's not customisable, so it doesn't suit.
For reference, I used sample code from this article which I found in this Github discussion
I've tried different approaches: using ExchangeFilterFunction
and WebFilter
+ ServerHttpRequestDecorator
(and other decorators) where I try to get body from DataBuffer
. Still no luck.