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

Just to close on this, I found a solution:

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().

We need to take advantage of a JettyCustomizer.

In WebApplication we add the property:
properties.put(JettyConstants.CUSTOMIZER_CLASS, "org.eclipse.orion.server.jettycustomizer.OrionJettyCustomizer");

And the OrionJettyCustomizer is a class extending the abstract JettyCustomizer in a fragment of org.eclipse.equinox.http.jetty. We override the customizeContext() method and include the code I mention below.

Cheers...
Anthony




From:        Joakim Erdfelt <joakim@xxxxxxxxxxx>
To:        JETTY user mailing list <jetty-users@xxxxxxxxxxx>
Date:        2014/03/07 01:19 PM
Subject:        Re: [jetty-users] Adding a handler so I can get HTTP-access logs for an Orion server
Sent by:        jetty-users-bounces@xxxxxxxxxxx




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>
webtide.com - intalio.com/jetty
Expert advice, services and support from from the Jetty & CometD experts
eclipse.org/jetty - cometd.org


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

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


Back to the top