I did a little more research and found out what's causing this conflict between 
newer versions of Jetty, and Log4j.

When the AbstractLifeCycle class is loaded in Jetty 7.5.0, it initializes its 
static LOG field which results in a getLogger call, initializing the Log4j 
framework. At this time, the "log4j.configuration" system property is unset. 
ObjectWithFieldsConverter.processConfiguration is later invoked, which sets the 
system properties appropriately. However, by this time, log4j has already been 
initialized improperly because of AbstractLifeCycle's getLogger invocation.

Back in Jetty 7.4.5, setProperty was invoked by 
ObjectWithFieldsConverter.processConfiguration, but the log was not initialized 
until later. There were no Jetty calls to getLogger, so the logging system 
wasn't initialized until my web application started up. The 
AbstractLifeCycle.LOG field is new to Jetty 7.5.0, and causes the Log4j system 
to be initialized before the jetty-maven-plugin has a chance to set system 
properties.

I was able to work around this problem by using the properties-maven-plugin 
(http://mojo.codehaus.org/properties-maven-plugin/) to set the system property 
before Jetty's AbstractLifeCycle class is loaded. However, this seems like a 
regression in Jetty since after Jetty 7.5.0, the SystemProperties parameter can 
no longer be used to initialize logging systems like log4j. This regression 
seems like it would also affect any other logging systems which lazily 
initialize in response to the first getLogger call.

- Aaron

-----Original Message-----
From: [email protected] [mailto:[email protected]] 
On Behalf Of Jan Bartel
Sent: Monday, May 21, 2012 10:07 AM
To: JETTY user mailing list
Subject: [SPAM] Re: [jetty-users] jetty-maven-plugin v7.5.0.v20110901 no longer 
respects system properties?
Importance: Low

Can you print out or otherwise examine what the value of the SystemProperty 
that is set via the pom.xml is at runtime? AFAIK, the system property stuff has 
not changed in a long time ... BTW,
jetty-7.5 is still a very old version, the most recent being 7.6.3.

Jan

On 15 May 2012 20:44, Pieper, Aaron <[email protected]> wrote:
> I run Jetty via the jetty-maven-plugin, from the command line, with a 
> command like "mvn jetty:run". After upgrading from jetty-maven-plugin
> v7.4.5.v20110725 to v7.5.0.v20110901, my log4j.properties file is no 
> longer being parsed. It is not being parsed because the 
> log4j.configuration system property is no longer being set when 
> running Jetty. I have this configuration in my pom.xml...
>
>
>
> <plugin>
>
> <groupId>org.mortbay.jetty</groupId>
>
> <artifactId>jetty-maven-plugin</artifactId>
>
> <version>7.5.0.v20110901</version>
>
> <configuration>
>
>   <war>${project.build.directory}/${webappName}.war</war>
>
>   ... snip ...
>
>   <systemProperties>
>
>   <systemProperty>
>
>     <key>log4j.configuration</key>
>
>     
> <value>file:${project.build.outputDirectory}/log4j.properties</value>
>
>   </systemProperty>
>
>
>
> As of Jetty v7.5.0, this log4j.configuration system property is no 
> longer being respected. I can still set the property via the command 
> line with "mvn jetty:run 
> -Dlog4j.configuration=file:./target/classes/log4j.properties",
> this works fine. I suspect this problem is due to a change in syntax 
> of the systemProperties xml element.
>
>
>
> There is documentation for setting up the systemProperties element 
> with the Jetty 6 plugin 
> (http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin#MavenJettyP
> lugin-sysprops), but I cannot find any comparable documentation for 
> the Jetty 7 plugin. The closest thing I can find
> (http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin) says, "For 
> more information, see Setting System Properties," but there is no 
> hyperlink anywhere. Was this omitted accidentally?
>
>
>
> Thanks,
>
>
>
> - Aaron
>
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to