Posts Tagged ‘httpbuilder’

Logging HttpBuilder traffic

Posted in Code on October 18th, 2013 by ataylor284 – Comments Off on Logging HttpBuilder traffic

Groovy and HttpBuilder are a nice way to write quick scripts to exercise web services. It’s especially useful when it’s just a bit too complex for something like curl. Unfortunately, there’s no quick way to trace all the I/O as with curl’s –trace, but turning on logging isn’t too difficult.

HttpBuilder uses HttpClient, which does some logging with Apache’s commons-logging. Without any additional libraries or configuration, it will fall back on Java’s java.util.logging package. Java expects it’s logging configuration in a properties file. Here’s a minimal config:

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=FINEST
.level=FINEST
httpclient.wire.header.level=FINEST
org.apache.commons.httpclient.level=FINEST

Launch groovy with the right system property, and all the output will be logged.

groovy -Djava.util.logging.config.file=logging.properties \
  MyHttpBuilderScript.groovy