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

3

10

i am currently using the RestClient and cannot seem to figure out how to output the request xml and response xml for debugging and informational purpose...

I tried the solution mentioned here: http://agileice.blogspot.com/2009/09/pretty-printing-xml-results-returned.html

But that fails to work, any other suggestions?

Reducer answered 22/10, 2011 at 8:12 Comment(0)
D
3

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

Demirep answered 29/10, 2011 at 2:48 Comment(0)
S
11

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
Soble answered 18/11, 2015 at 6:39 Comment(0)
D
3

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

Demirep answered 29/10, 2011 at 2:48 Comment(0)
C
0

If you're using spring-boot you can set logging.level in your application properties file and use an slf4j back-end.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>${slf4j.version}</version>
</dependency>

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>${logback.version}</version>
</dependency>
Clow answered 22/1, 2019 at 20:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.