Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I log response in Spring RestTemplate?

I am using RestTemplate to make calls to a web service.

String userId = restTemplate.getForObject(createUserUrl, String.class);

If this fails to return a user ID I just get returned null but I don't know why. How do I output the actual XML response to a log?

like image 703
rjsang Avatar asked Oct 08 '10 15:10

rjsang


People also ask

What is ClientHttpRequestInterceptor?

Interface ClientHttpRequestInterceptor This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference. @FunctionalInterface public interface ClientHttpRequestInterceptor. Intercepts client-side HTTP requests.


1 Answers

Depending on which method of making the HTTP connection you are using, you could look at turning up the logging within the actual HTTP connection classes.

For example, if you are using commons HttpClient, you can set

log4j.logger.httpclient.wire=DEBUG

The commons-httpclient project has an entire page in the documentation on their logging practices.

like image 99
matt b Avatar answered Sep 24 '22 07:09

matt b