[slf4j-dev] Add a logging.properties to jul-to-slf4j?

Robert Elliot rob at lidalia.org.uk
Tue May 8 23:34:15 CEST 2012


Hi Ceki,

I understand where you are coming from on not over-riding the full JUL config.  I think the argument in favour of doing so would run like this:

* jul-to-slf4j is explicitly for end-applications (not libraries or modules) that want to redirect JUL to SLF4J, in order to manage their logging via an SLF4J implementation that does not use JUL.  As such the user has implicitly decided not to have any other JUL config by including jul-to-slf4j in the first place.  The act of including this jar on the class path could, as such, be interpreted as "being" the configuration of JUL logging.
* this is effectively what log4j-over-slf4j does - you cannot use log4j-over-slf4j and configure log4j separately.  By including it on the class path you "configure" log4j to redirect to slf4j.
* as a user you redirect log4j & commons-logging to slf4j simply by including log4j-over-slf4j and jcl-over-slf4j on the class path, so the user is already conditioned to expect that including the jar is all you need to do to consolidate your logging - it's actually mildly surprising to find that for jul-to-slf4j you have to include the jar and configure JUL.

I can't immediately think of a use case where one would want to configure the SLF4JBridgeHandler and configure other JUL handlers; it seems contradictory to me.  Which is not to say there are none, of course.

Having said all of which, I didn't feel entirely comfortable with it myself!  It was just a thought.

On 8 May 2012, at 14:02, ceki wrote:

> Hi Robert,
> 
> I modified the javadocs for SLF4JBridgeHandler
> 
> Programmatic installation:
> 
> // Optionally remove existing handlers attached to j.u.l root logger
> SLF4JBridgeHandler.removeHandlersForRootLogger(); // (since SLF4J 1.6.5)
> 
> // add SLF4JBridgeHandler to j.u.l's root logger, should be done once
> // during the initialization phase of your application
> SLF4JBridgeHandler.install();
> 
> 
> Installation via logging.properties configuration file:
>   // register SLF4JBridgeHandler as handler for the j.u.l. root logger
>   handlers = org.slf4j.bridge.SLF4JBridgeHandler
> 
> Your comments welcome.
> 
> By the way, the javadocs for SLF4JBridgeHandler state
> that"essentially, the idea is to install on the root logger an
> instance of SLF4JBridgeHandler as the sole JUL handler in the system."
> I think the word "sole" goes a little over board. If the user wishes
> to use other handlers, they are welcome to do so. (We have no mandate
> to tacitly override jul config.)
> 
> -- 
> Ceki
> http://twitter.com/#!/ceki
> 
> On 08.05.2012 13:55, ceki wrote:
>> Hi Robert,
>> 
>> I had not considered overwriting the logging.properties file. It's a
>> great idea. I'll document it shortly. Having said that, including
>> logging.properties in jul-to-slf4j.jar would be an indefensible case
>> of "do as say not as i do" [1]. Our credibility aside, does
>> jul-to-slf4j.jar have the mandate to override j.u.l. configuration? I
>> don't think jul-to-slf4j.jar has any such mandate...
>> 
>> Cheers,
>> 
>> [1] http://www.slf4j.org/faq.html#configure_logging
> 
> 
> _______________________________________________
> slf4j-dev mailing list
> slf4j-dev at qos.ch
> http://mailman.qos.ch/mailman/listinfo/slf4j-dev



More information about the slf4j-dev mailing list