Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetty HTTP logging

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.

like image 454
Steve Kuo Avatar asked Dec 06 '12 01:12

Steve Kuo


People also ask

How do I check my jetty logs?

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.

Is jetty using log4j?

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.

What is Jetty logs?

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.

What is Jetty service?

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.


1 Answers

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

like image 54
Thomas Becker Avatar answered Oct 06 '22 01:10

Thomas Becker