我正在使用 RestTemplate 调用 Web 服务。
String userId = restTemplate.getForObject(createUserUrl, String.class);
如果这未能返回用户 ID,我只会返回 null,但我不知道为什么。如何将实际的 XML 响应输出到日志?
最佳答案
根据您使用的建立 HTTP 连接的方法,您可以查看在实际 HTTP 连接类中打开日志记录。
例如,如果你使用的是commons HttpClient,你可以设置
log4j.logger.httpclient.wire=DEBUG
commons-httpclient 项目有 an entire page in the documentation on their logging practices .
关于java - 如何在 Spring RestTemplate 中记录响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3892018/