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.
By default all jetty logs are placed into jetty/base/logs directory. The main Rhythmyx log can be found at jetty/base/logs/server. log If this file gets too big >10Mb the logging engine will roll over to separate files server.
Apache log4j is a popular logging library. Jetty supporst log4j via Jetty via the Slf4j facade and the Slf4j binding layer for log4j . The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks, such as java. util.
jetty. util. log. Logger layer, and does not natively use any existing Java logging framework. All logging events, produced via the Jetty logging layer, will have a name, a level, and a message.
Jetty provides a web server and servlet container, additionally providing support for HTTP/2, WebSocket, OSGi, JMX, JNDI, JAAS and many other integrations. These components are open source and are freely available for commercial use and distribution.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With