[slf4j-dev] Review of slf4j

Niclas Hedhman niclas at hedhman.org
Mon May 16 07:57:19 CEST 2005


On Monday 16 May 2005 12:44, Jacob Kjome wrote:
> Logging is not critical to the functioning of the class.  The only
> advantage I can see to exposing loggers is being able to name them in
> configuration.  However, a consistent naming scheme such as
> MyClass.class.getName() should resolve that issue and avoid pushing this
> work out to the IOC configurator.  And given the existence of slf4j, being
> a non-harmful logging framework (as opposed to common-logging crashing
> applications because of its brittle discovery process) and a tiny
> dependency (especially with the optional NOP implementation),  I just think
> that logging is a different beast that IOC need not be concerned with.

You are making a fair amount of assumptions right there.

What if I want to be able to extend the Logger framework with additional 
"Appenders" or "Formatters" in runtime, without taking down the application 
and having 3rd party dependencies in these extensions?
Then classloading is a must, and the concern of the application framework.

You are assuming that the Logger.getLogger( MyClass.class ) fulfills the 
needs. The NDC and MDC is an expression that this is not the case.
Troubleshooting is another area where non-classbased output channels are 
convenient. Assume for a second that you have a problem in a subsystem, but 
stuff happening inside a really lowlevel class (java.net.URL as a stupid 
example), but if you turn on debug-level on that class you would flood the 
output channels beyond managability. Or, the application is heavily threaded, 
and you want per-thread outputs/level-settings. Or, you want per-user 
outputs. I am sure there is an endless list and various hacks available to 
make it happen. But, a properly arranged application framework, with the help 
of the IoC pattern, could solve them all. Logger.getLogger( MyClass.class ) 
can not solve them all.

Logging CAN be used as a critical part of an application, both in form of 
heart-beat as well as for 'accountability' and 'audit'. My current engagement 
actually does this (not my idea!).


But we are discussing an API here, and I think we can achieve both worlds with 
small means (see other mail) which I don't think impact the users very much, 
and still makes it easy to implement for Log4J and other.


Cheers
Niclas



More information about the slf4j-dev mailing list