I\'m trying to log a request using Spring 5 WebClient. Do you have any idea how could I achieve that?
(I\'m using Spring 5 and Spring boot 2)
The code looks
@StasKolodyuk's answer elaborates on the solution from baeldung for logging the response body of a reactive WebClient. Note that
tc.bootstrap(...)
is deprecated in
HttpClient httpClient = HttpClient
.create()
.tcpConfiguration(
tc -> tc.bootstrap(
b -> BootstrapHandlers.updateLogSupport(b, new CustomLogger(HttpClient.class))))
.build()
Another non-deprecated way to add your custom LoggingHandler is (Kotlin)
val httpClient: HttpClient = HttpClient.create().mapConnect { conn, b ->
BootstrapHandlers.updateLogSupport(b, CustomLogger(HttpClient::class.java))
conn
}