[logback-user] Legacy Log4j Question

Robert Elliot rob at lidalia.org.uk
Wed Oct 27 14:46:04 CEST 2010


The question has to be why do your dependent jars need to call these APIs in log4j?  Unfortunately log4j does not differentiate between the interface for firing off log events (the sort of thing SLF4J/Commons logging provide) and its API for managing what is actually done for them.  As a general rule libraries should only be using the bare minimum of logging (the equivalent of the SLF4J interface - which is what log4j-over-slf4j implements) and only the end user application should be defining things like appenders and turning logging on or off.

If your dependent jars are using the log4j API for controlling what is done with logging events then either they have a real dependency on log4j for some good reason or else they are behaving badly.  Without knowing what these dependencies are, what they are doing and why there's not much else can be said.

(Of course you always have the option of using log4j as your slf4j implementation via slf4j-log4j; you can still pipe JULI & Commons Logging to SLF4J and use SLF4J in your own code and so end up with a single logging config file, just a log4j one rather than a logback one.)

----- Original Message -----
> From: "Jeremy Truelove" <Jeremy.Truelove at barclayscapital.com>
> To: logback-user at qos.ch
> Sent: Wednesday, 27 October, 2010 1:30:22 PM
> Subject: [logback-user] Legacy Log4j Question
> So I've been porting some of our services to use Logback over log4j
> and I've been using the log4j-over-slf4j jar to spoof log4j for our
> legacy dependencies. The only issue is log4j-over-slf4j doesn't
> implement many of the classes of log4j so I'm seeing a decent few
> class not found exceptions from dependent jars. How have people got
> around this? Is it enough to just put the nlog4j in your classpath
> instead of the log4j-over-slf4j jar? I’d still like to use one logback
> config file to drive all my logging to a single log file. Thanks.
> 
> jt
> 
> _______________________________________________
> 
> 
> 
> This e-mail may contain information that is confidential, privileged
> or otherwise protected from disclosure. If you are not an intended
> recipient of this e-mail, do not duplicate or redistribute it by any
> means. Please delete it and any attachments and notify the sender that
> you have received it in error. Unless specifically indicated, this
> e-mail is not an offer to buy or sell or a solicitation to buy or sell
> any securities, investment products or other financial product or
> service, an official confirmation of any transaction, or an official
> statement of Barclays. Any views or opinions presented are solely
> those of the author and do not necessarily represent those of
> Barclays. This e-mail is subject to terms available at the following
> link: www.barcap.com/emaildisclaimer . By messaging with Barclays you
> consent to the foregoing. Barclays Capital is the investment banking
> division of Barclays Bank PLC, a company registered in England (number
> 1026167) with its registered office at 1 Churchill Place, London, E14
> 5HP. This email may relate to or be sent from other members of the
> Barclays Group.
> 
> _______________________________________________
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user


More information about the Logback-user mailing list