Community
Participate
Working Groups
I'm actually using Jetty 7.1.6 as an OSGi bundle to build a webapp structured as a set of web-bundles (as described in <http://wiki.eclipse.org/Jetty/Tutorial/Jetty-OSGi_SDK>. I'm using the 'jetty.home.bundle' property (fantastic idea, btw). I would like to define a different location for the Jetty log files, something independent of the 'jetty.home' property, and so I thought I'd use a new property to specify the location for log files ('jetty.logs'). I pass '-Djetty.logs=/tmp/jetty-logs' on the command line, and I can see that it's available through System.getProperty("jetty.logs"), but it's not being used when parsing the jetty.xml. I even set a bp on XmlConfiguration#propertyObj() to check. It turns out the XmlConfiguration is being provided a property-dictionary munged by org.eclipse.jetty.osgi.boot.internal.serverfactory.JettyServerServiceTracker.serviceChanged() from the properties provided by the ServiceReference. Unfortunately this properties list has only 4 elements: {service.id=28, objectClass=[Ljava.lang.String;@7badb7b8, managedServerName=defaultJettyServer, jetty.etc.config.urls=bundleentry://9.fwk204442458/etc/jetty.xml} and no system properties are being passed. This may mean that the 'jetty.home' isn't being properly set either. I think this properties dictionary should be augmented with the system properties too. Steps to repeat: * Create a simple servlet bundle (e.g., example.servlet). * Add an etc/jetty.xml. * Change the RequestLog's location to use a 'jetty.logs' property. E.g., <Ref id="RequestLog"> <Set name="requestLog"> <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog"> <Set name="filename"><Property name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set> ... * Create a suitably-configured run configuration, and add '-Djetty.logs=/tmp' to the VM arguments * Run the configuration. Note that the logs are not being put in /tmp. Place a breakpoint in org.eclipse.jetty.xml.XmlConfiguration#propertyObj() and notice the very small properties dictionary.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=323985 This is an extension of that above issue...you can see how greg resolved the issue at the bottom which I believe will not resolve it here, but would a similar approach in this case? Seems like it would as its largely doing the same thing. I'll dig a bit in the code and might just add that in.
You could also use SystemProperty instead of Property in that bit of xml you have there and that should work.
Thanks Jesse. Brian, Glad that jetty.home.bundle is useful for you. It sounds like you want to use the SystemProperty itself: <Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set> Given that system properties are available to the XmlConfiguration I am not convinced that passing the system properties as part of the properties map is useful. Does this solve the issue?
Thanks for the pointers. SystemProperty works for me.
alternate solution identified, closing