Debug RestTemplate Post request

I am trying to POST to a REST-API using RestTemplate in Spring. Here is the code I am using:

//Code to Post data using Rest Template
List<UserVO> userList = getUsers();
RestRequestVO submitRequestData = new RestRequestVO();
ResponseEntity<String> resposne = restTemplate.postForEntity(putUserUrl, submitRequestData, String.class);
String message = resposne.getBody();

//The structure of class
public class RestRequestVO {
private String action;
private String type;
private List<UserVO> items;

//Setters and Getters

//Expected JSON
    { //user1 }, {//user2} ....

I need to debug this properly and see what is the exact JSON being sent to the REST server by restTemplate.postForEntity(putUserUrl, submitRequestData, String.class); line.

I am using Eclipse. I have tried debugging code line by line. I have also tried setting log-level to Debug.

UPDATE after following steps given in comments

Below is my log4j.xml, I can not see any http logs related to REST Template. Please let me know if I have done some mistake.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j=''>

    <appender name="CA" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss,SSS} - %5t - %5p - %l  - %m%n" />

    <appender name="FA" class="org.apache.log4j.FileAppender">
        <param name="File" value="cw.log"/>
        <param name="Threshold" value="DEBUG"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss,SSS} - %5t - %5p - %l  - %m%n" />

    <logger name="log4j.logger.httpclient.wire" additivity="false" > 
    <level value="DEBUG" /> 
    <appender-ref ref="CA"/> 

        <level value="Debug" />
        <appender-ref ref="CA" />


I intend to print JSON which is being created from POJO before it is sent to REST POST URL.


You can set breakpoint in AbstractHttpMessageConverter at the end of the public final void write(final T t, MediaType contentType, HttpOutputMessage outputMessage) method, and evaluate outputMessage.getBody()

AFAIK, usually setting the log level helps, but may be you have the similar situation described here (see not accepted answer) or here.

Need Your Help

Installer for .NET 2.0 application for Windows 98

.net windows visual-studio-2008 .net-2.0 setup-project

How can an automatic installer for .NET 2.0 application be created for Windows 98?

display drop down values using javascript or jquery

javascript jquery

I have following code to add values in drop down, values are getting added but that are not getting displayed in the drop down, i have tested it by reading values after adding in drop down by using