How to output the generated request and response from Groovy RestClient?

Since it depends on HTTPClient, you could try enabling header and wire logging for your script.

http://blog.techstacks.com/2009/12/configuring-wire-logging-in-groovy-httpbuilder.html

http://hc.apache.org/httpcomponents-client-ga/logging.html


The accepted answer (turn on wire logging using log4j) is basically correct, but I've had a fair bit of trouble turning on wire logging for HTTP builder in my Groovy script. For some reason, dropping a log4j.xml file in my $GROOVY_HOME/conf directory isn't working. Ultimately, I had to just add the appropriate logging options to the groovy command when I was running it.

groovy 
    -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog 
    -Dorg.apache.commons.logging.simplelog.showdatetime=true 
    -Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG 
    myscript.groovy