Skip to content

Instantly share code, notes, and snippets.

@rjnienaber
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjnienaber/753a8f488851358e30b1 to your computer and use it in GitHub Desktop.
Save rjnienaber/753a8f488851358e30b1 to your computer and use it in GitHub Desktop.
Enable http logging for http_client without code changes (JRuby)
jruby -J-Djava.util.logging.config.file=logging.properties test.rb 2>&1 | grep FINE
.level=FINER
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level = FINER
org.apache.http.impl.conn.Wire.level=FINER
FINE: Get connection for route HttpRoute[{}->http://httpbin.org:80]
FINE: Connecting to httpbin.org/54.175.222.246:80
FINE: CookieSpec selected: best-match
FINE: Auth cache not set in the context
FINE: Attempt 1 to execute request
FINE: Sending request: GET /get? HTTP/1.1
FINE: >> "GET /get? HTTP/1.1[\r][\n]"
FINE: >> "Host: httpbin.org:80[\r][\n]"
FINE: >> "Connection: Keep-Alive[\r][\n]"
FINE: >> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"
FINE: >> "[\r][\n]"
FINE: >> GET /get? HTTP/1.1
FINE: >> Host: httpbin.org:80
FINE: >> Connection: Keep-Alive
FINE: >> User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
FINE: << "HTTP/1.1 200 OK[\r][\n]"
FINE: << "Server: nginx[\r][\n]"
FINE: << "Date: Wed, 15 Apr 2015 07:28:10 GMT[\r][\n]"
FINE: << "Content-Type: application/json[\r][\n]"
FINE: << "Content-Length: 187[\r][\n]"
FINE: << "Connection: keep-alive[\r][\n]"
FINE: << "Access-Control-Allow-Origin: *[\r][\n]"
FINE: << "Access-Control-Allow-Credentials: true[\r][\n]"
FINE: << "[\r][\n]"
FINE: Receiving response: HTTP/1.1 200 OK
FINE: << HTTP/1.1 200 OK
FINE: << Server: nginx
FINE: << Date: Wed, 15 Apr 2015 07:28:10 GMT
FINE: << Content-Type: application/json
FINE: << Content-Length: 187
FINE: << Connection: keep-alive
FINE: << Access-Control-Allow-Origin: *
FINE: << Access-Control-Allow-Credentials: true
FINE: Connection can be kept alive indefinitely
FINE: << "{[\n]"
FINE: << " "args": {}, [\n]"
FINE: << " "headers": {[\n]"
FINE: << " "Host": "httpbin.org", [\n]"
FINE: << " "User-Agent": "Apache-HttpClient/4.1.1 (java 1.5)"[\n]"
FINE: << " }, [\n]"
FINE: << " "origin": "31.221.100.54", [\n]"
FINE: << " "url": "http://httpbin.org/get"[\n]"
FINE: << "}[\n]"
FINE: Releasing connection org.apache.http.impl.conn.SingleClientConnManager$ConnAdapter@77f11652
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment