I want to automate the request/response logging, including response body., for evrey RestClient call.
RestClient client = RestClient.builder()
.requestInterceptor((request, body, execution) -> {
ClientHttpResponse response = execution.execute(request, body);
byte[] requestBody = StreamUtils.copyToByteArray(response.getBody()); //Consume response body, so I get null if I try to consume it again
System.out.println(new String(requestBody));
return response;
}).build();
ClientHttpRequestInterceptor gets me 90% there, I can log everything else except the response body, because I wont be able to consume it where I am making the call, If I log it in the ClientHttpRequestInterceptor.
Comment From: bclozel
Thanks for getting in touch, but it feels like this is a question that would be better suited to StackOverflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Comment From: Aleksander-Dorkov
Isn't this an echancment request? The feature doesn't exist, there is no way to do it.
Comment From: jonathanwiemers
Hey @Aleksander-Dorkov did you find an other way to do this?