Jetty HTTP logging

Steve Kuo picture Steve Kuo · Dec 6, 2012 · Viewed 19.1k times · Source

I would like to have Jetty log all HTTP requests (along with the body) and responses. Is this natively supported by Jetty? Ideally it would log to my existing log4j log file.

I am running Jetty 6.

Answer

Thomas Becker picture Thomas Becker · Dec 6, 2012

Jetty comes with a request logger that can log in NCSA format. That format doesn't include things like request body as you require, but that standard format will fit tools like webalizer and the like.

If you need to log more you can use the logback request log implementation or write your own logger by implementing Jetty's RequestLog interface.

Besides that I'd highly recommend to upgrade to jetty7/8 (same codebase, but 8 provides servlet 3.0 functionality). Or directly move to jetty9.

Here's the jetty9 documentation for request logs: http://www.eclipse.org/jetty/documentation/current/configuring-logging.html#configuring-jetty-request-logs

Same for jetty7/8: http://wiki.eclipse.org/Jetty/Tutorial/RequestLog

I leave it as an exercise for you to find the jetty6 docs or better yet, upgrade. :)

Ok, just found the jetty6 docs by accident: http://docs.codehaus.org/display/JETTY/Logging+Requests