7 date: "2015-02-09T10:52:15+00:00"
8 guid: http://juplo.de/?p=326
11 title: Logging Request- and Response-Data From Requets Made Through RestTemplate
12 url: /logging-request-and-response-data-from-requets-made-through-resttemplate/
15 Logging request- and response-data for requests made through Spring's `RestTemplate` is quite easy, if you know, what to do.
16 But it is rather hard, if you have no clue where to start.
17 Hence, I want to give you some hints in this post.
19 In its default configuration, the `RestTemplate` uses the [HttpClient](https://hc.apache.org/httpcomponents-client-4.4.x/index.html "Visit the project homepage of httpcomponents-client") of the [Apache HttpComponents](https://hc.apache.org/index.html "Visit the project homepage of apache-httpcomonents") package.
20 You can verify this and the used version with the mvn-command
28 To enable for example logging of the HTTP-Headers send and received, you then simply can add the following to your logging configuration:
32 <logger name="org.apache.http.headers">
33 <level value="debug"/>
40 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 `3.x` and `4.x`.
41 Another common cause of problems is, that the Apache HttpComponets uses [Apache Commons Logging](http://commons.apache.org/proper/commons-logging/ "Visit the project homepage of commons-logging").
42 If the jar for that library is missing, or if your project uses another logging library, the messages might get lost because of that.