Facebook Developer Garage in Palo Alto Face ‘IM: The social graph outside
Aug 27

SLF4J: Now you can do logging in Java… oh wait!

Tech Add comments

Howard is saying so long, commons-logging, hello SLF4J.

I had to giggle a little bit here. When commons-logging came along to abstract your logger which abstracts your println (I know…. you CAN write an appender that sends you SMS messages and launches rockets) I thought “wow”.

Only the J2EE community would architect twelve levels of abstraction to handle a filtered logging system.

After years of use we realise that the last level of abstraction doesn’t do anything for you… but instead of just ignoring it, we have a new one!

The non-Apache follow on to commons-logging is SLF4J. It does things right: Logger, not Log. Better yet, Logger is an interface (it’s a class in Log4J) which makes my EasyMock-addled brain quite happy. Finally, SLF4J takes a very simple, very sane approach: you combine the API JAR with one of several implementation JARs. That’s it … no class loader magic, no dynamic binding. This is an ideal solution for those same 99.99999% of applications out there.

Maybe someone could write an abstraction layer on top of commoons-logging and SLF4J…. you know, so you could switch between then without changing the interface.

4 Responses to “SLF4J: Now you can do logging in Java… oh wait!”

  1. Arthur Blake Says:

    SLF4J does already come with two abstractions for interacting with commons logging– one jar that emulates commons logging and can completely replace the commons-logging jar and another one that sends it’s logging messages to commons logging as it’s target logging system.

  2. Anonymous Says:

    I prefer to do all my logging to paper.

  3. Johhny Says:

    I prefer reading intelligent discussions.

  4. Marcel Says:

    It’s clear you have never tried to run commons-logging applications on WebSphere: there are event documented workarounds for this. ClassLoader tricks should not be part of any library that you might include in your applicatoin as the pain will come one day..

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What are the first four letters in the word British?