Hi Chris, the NCSA logger is not configured by means of a jetty.xml, it's configured through the pax web properties configuration / configuration admin. Never the less you did choose the right approach to add another RequestLogger. Though you don't need use a fragment bundle. ServiceMix/Karaf uses a file based jetty.xml which is placed in the etc folder, you just need to alter that one.
The jetty.xml seems to be correct. A simpler approach by using a service might be an interesting idea, though it's not supported yet. regards, Achim 2014-12-22 23:49 GMT+01:00 Christoffer Soop <[email protected]>: > > Hi, > > I am trying to replace the NCSA log with a custom RequestLog > implementation in ServiceMix 4.5.3. I started out by lookging at > > https://wiki.eclipse.org/Jetty/Tutorial/RequestLog < > https://wiki.eclipse.org/Jetty/Tutorial/RequestLog> > > ... but quickly realized I should probably not replace the OPS4J Pax Web > configuration. Instead I should extend it following the tutorial at > > > https://ops4j1.jira.com/wiki/display/paxweb/Advanced+Jetty+Configuration < > https://ops4j1.jira.com/wiki/display/paxweb/Advanced+Jetty+Configuration> > > I have thus created a Jetty configuration fragment like so: > > <?xml version="1.0"?> > <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting// > DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd < > http://jetty.mortbay.org/configure.dtd>"> > <Configure class="org.eclipse.jetty.server.Server"> > <Get name="handler"> > <Call name="addHandler"> > <Arg> > <New > id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"> > > <Set name="requestLog"> > > <New id="RequestLogImpl" > class="edu.loopback.jetty.CustomJettyRequestLog" /> > > </Set> > </New> > </Arg> > </Call> > </Get> > </Configure> > > This I hope will a) fetch the Server configuration and b) add my > CustomJettyRequestLog to a new RequestLogHandler, assuming it can co-exist > peacfully with the existing NCSA RequestLogHandler. Replacing the default > handler would seem like a better option but I have no clue on how to go > about this… > > Just installing my fragment does not seem to make a difference and when I > refresh the OPS4J Pax Web - Jetty bundle I get the following error: > > 23:04:39,477 | ERROR | g.ops4j.pax.web) | configadmin > | 5 - org.apache.felix.configadmin - 1.2.8 | Configuration for > org.ops4j.pax.web has already been used for service > [org.osgi.service.cm.ManagedService, id=85, bundle=138] and will now also > be given to [org.osgi.service.cm.ManagedService, id=293, bundle=138] > > This I take to meet that instead of merging my configuration, a new Jetty > configuration is added. > > My guess is that I need to make sure that my bundle is loaded before the > Fragment-Host org.ops4j.pax.web.pax-web-jetty in order to make it the merge > with the Fragement-Host when starting the Pax Jetty bundle. From what I can > tell this means I should > create a feature > add the service to the startup.properties with a start level below > (similar to?) the OPS4J Pax Web Jetty bundle > add the feature and feature repository to org.apache.karaf.features.cfg > add my bundle to the system repository folder > As I am already swimming in deep water I would much appreciate any > feedback on this - in particular if somebody could please validate the > approach confirming that > Changing the default NCSA RequestLog implementation requires a Pax Web > Jetty fragment > The fragment needs to start before Pax Web Jetty > The jetty.xml is correct > Of course, if there is a simpler way to switch to my custom RequestLog I > am all ears… One could dream of a simple property with a class name > somewhere... > > Best regards, > > Chris -- Apache Member Apache Karaf <http://karaf.apache.org/> Committer & PMC OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead blog <http://notizblog.nierbeck.de/> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS> Software Architect / Project Manager / Scrum Master
