Logging Request- and Response-Data From Requets Made Through RestTemplate
Logging request- and response-data for requests made through Spring’s
RestTemplate is quite easy, if you know, what to do.
But it is rather hard, if you have no clue where to start.
Hence, I want to give you some hints in this post.
To enable for example logging of the HTTP-Headers send and received, you then simply can add the following to your logging configuration:
If that does not work, you should check, which version of the Apache HttpComponents your project actually is using, because the name of the logger has changed between version
Another common cause of problems is, that the Apache HttpComponets uses Apache Commons Logging.
If the jar for that library is missing, or if your project uses another logging library, the messages might get lost because of that.