Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Adding a handler so I can get HTTP-access logs for an Orion server

You are not hacking the jetty source. honest.

A thought,
Orion could hook into the XML based configuration options for jetty, which would allow you supply some XML configuration files to supplement the running Jetty instance.
But in reality, that is really no different than what you are currently doing.
You either do the work in XML or in Java, same effort, same code being executed, same end result.

--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Fri, Mar 7, 2014 at 9:58 AM, Anthony Hunter <anthonyh@xxxxxxxxxx> wrote:
Hi Team,

I am trying to enable HTTP-access logs for Orion. Details are at https://bugs.eclipse.org/bugs/show_bug.cgi?id=429063#c3

If you look at https://wiki.eclipse.org/Jetty/Howto/Configure_Request_Logs and some of the other documentation, it suggests I need to add an handler to the Jetty server.

Our WebApplication in org.eclipse.orion.server.configurator makes use of a JettyConfigurator to start the server. The JettyConfigurator calls startServer() that eventually calls HttpServerManager.updated().

In this updated() method I can comment out the handler line:
        //server.setHandler(httpContext);

and replace it with what is suggested in the Jetty documentation:
        HandlerCollection handlers = new HandlerCollection();
        ContextHandlerCollection contexts = new ContextHandlerCollection();
        RequestLogHandler requestLogHandler = new RequestLogHandler();
        handlers.setHandlers(new Handler[]{contexts,httpContext,requestLogHandler});
        server.setHandler(handlers);
                 
        NCSARequestLog requestLog = new NCSARequestLog("./logs/jetty-yyyy_mm_dd.request.log");
        requestLog.setRetainDays(90);
        requestLog.setAppend(true);
        requestLog.setExtended(true);
        requestLog.setLogTimeZone("EST");
        requestLogHandler.setRequestLog(requestLog);

This gives me exactly what I am looking for, but obviously I am hacking the jetty source and need to find the right way to do this, either through an extension point or the like.

Unfortunately I cannot seem to find anything. Any ideas on how to properly add a handler here?

Cheers...
Anthony

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top