Cấu hình đăng nhập của bạn như sau:
log4j.logger.org.springframework.web.client=DEBUG
Sau đó sử dụng một lệnh curl để xem kết quả, ví dụ như
curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' http://localhost:8080/ser/data
Theo mặc định, restTemplate sử dụng HttpURlConnection (thông qua SimpleClientHttpRequest), do đó bạn có thể cần để chuyển sang jakarta httpclient để xem báo cáo nhật ký. Nếu không cấu hình đăng nhập trên sẽ ra cho bạn thấy những phản ứng
<bean id="httpClientFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory">
<constructor-arg><bean class="org.apache.commons.httpclient.HttpClient"/></constructor-arg>
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<constructor-arg ref="httpClientFactory"/>
<property name="messageConverters">
...
Phản hồi XML nào? – skaffman
Bạn cũng có thể sử dụng LoggingRequestInterceptor cf http://stackoverflow.com/a/22620168/409784 – Francois
Resolved https://stackoverflow.com/questions/7952154/spring-resttemplate-how-to-enable-full- debugging-logging-of-requests-response/47467572 – user2746033