Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362795 - Replace jetty 8 StdErrLog with our own
Summary: Replace jetty 8 StdErrLog with our own
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Compendium (show other bugs)
Version: 3.8.0 Juno   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: Juno M4   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-03 10:09 EDT by Thomas Watson CLA
Modified: 2011-11-07 17:24 EST (History)
4 users (show)

See Also:
simon_kaegi: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Watson CLA 2011-11-03 10:09:24 EDT
By default, if there is no slf4j implementation present jetty will log to their built-in StdErrLog which posts everything to standard out.  We need to replace this with our own which disables all log messages by default.

In jetty 6 we seemed to have our own fake org.slf4j package included in our own bundle and then set the context class loader to our own bundle before invoking some jetty Log APIs and hoped that jetty would attempt to load our fake Logger.  Well in jetty 8 they no logger ask the context class loader for an slf4j implementation.  That is fine by me because this approach seemed rather clunky anyway.

For jetty 8 I think we should simply implement org.eclipse.jetty.util.log.Logger directly and use a StdErrLog impl under the covers to delegate to if our logging properties are set.
Comment 1 Thomas Watson CLA 2011-11-03 10:13:52 EDT
I released a fix in commit:

http://git.eclipse.org/c/equinox/rt.equinox.bundles.git/commit/?id=b28c8833ba841e3b1df5345ab0a8ea370e3756e0

I would appreciate a review of the approach by Hugues, and the two Simons if possible.
Comment 2 Hugues Malphettes CLA 2011-11-06 21:13:27 EST
(In reply to comment #1)
> I released a fix in commit:
> 
> http://git.eclipse.org/c/equinox/rt.equinox.bundles.git/commit/?id=b28c8833ba841e3b1df5345ab0a8ea370e3756e0
> 
> I would appreciate a review of the approach by Hugues, and the two Simons if
> possible.

Hi Tom, sorry for the delay.

Joakim and I reviewed this change.

Joakim's initial feedback was to use the system property "org.eclipse.jetty.util.log.class"
to plugin a different Logger's implementation.
This is back by this class:
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java

However, this type of plugin mechanism won't work nicely in OSGi.

We concluded that probably you wanted to leave the logging configuration of Jetty unchanged and override the default stderr logger.

Could you double confirm that is what we are doing here?
We are certainly not comfortable with the clunky approach that forces adopters of jetty in OSGi to put in place such clunky glue code.

Should we look into changing jetty-util's log to behave as nicely as possible in OSGi?
Comment 3 Thomas Watson CLA 2011-11-07 14:18:29 EST
(In reply to comment #2)
> Hi Tom, sorry for the delay.
> 
> Joakim and I reviewed this change.

Thanks!

> 
> Joakim's initial feedback was to use the system property
> "org.eclipse.jetty.util.log.class"
> to plugin a different Logger's implementation.
> This is back by this class:
> http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java
> 
> However, this type of plugin mechanism won't work nicely in OSGi.

Right, looking at the code, this seems similar to how we were overriding the log in jetty 6 although through a little different mechanism.  In Jetty 6 we would set the TCCL to our own bundle and fake jetty 6 out into thinking we provided an slf4j impl that return jetty loggers.  I really did not care for that and the same code path did not seem to exist in jetty 8.  So I did take a look at the org.eclipse.jetty.util.log.class property, but I do not like this because it also would require us to set the TCCL to our own bundle's class loader so that jetty 8 could find our log implementation class while we called Log.initialized().

I also do not like configuring this through system properties and was not sure if we could configure it differently.

> 
> We concluded that probably you wanted to leave the logging configuration of
> Jetty unchanged and override the default stderr logger.

Yes, we basically want to be able to configure what level of errors get written to stderr without setting system properties since jetty my be embedded in a java process for which we don't want to set the system wide properties on.

> 
> Could you double confirm that is what we are doing here?
> We are certainly not comfortable with the clunky approach that forces adopters
> of jetty in OSGi to put in place such clunky glue code.
> 
> Should we look into changing jetty-util's log to behave as nicely as possible
> in OSGi?
Comment 4 Simon Kaegi CLA 2011-11-07 17:24:14 EST
Looks good -- the extra check for -- !(rootLogger instanceof EquinoxStdErrLog) is no longer needed and can be removed.