Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Porting from Jetty 11 to Jetty 12. Missing RequestLogHandler

I am porting application that uses Jetty as a HTTP server from Jetty 11 to Jetty 12.

I have problem with RequestLogHandler class, which seems to be missing in Jetty 12.

var address = new InetSocketAddress(settings.getBindingInterface(), settings.getPort());
var jettyServer = new Server(address);
var handler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
handler.setContextPath("/");

var statisticsHandler = new StatisticsHandler();
statisticsHandler.setHandler(handler);

var requestLogHandler = new RequestLogHandler();
requestLogHandler.setHandler(statisticsHandler);

var requestLog = new CustomRequestLog(new Slf4jRequestLogWriter(), CustomRequestLog.NCSA_FORMAT);
requestLogHandler.setRequestLog(requestLog);
handler.setErrorHandler(new MyErrorHandler());
jettyServer.setHandler(requestLogHandler);

Can you help me to:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • confirm that RequestLogHandler is now gone (and not moved to a separate artifact)
  • optionally, find the pull request that introduced that change
  • write equivalent code in Jetty 12

>Solution :

Use Server.setRequestLog(RequestLog) instead.

The RequestLogHandler was an artifact from the Jetty 5 thru Jetty 9 era.

It was heavily neutered in Jetty 10, and does almost nothing compared to Jetty 9.

The use of Server.setRequestLog(RequestLog) is even mentioned in the javadoc for RequestLogHandler in Jetty 10/11.

The server level version logs all requests, even failures, errors, bad requests, request that don’t have a path, request that don’t match a context, etc…

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading