[slf4j-user] Java 5 version of SLF4J?

Ceki Gulcu listid at qos.ch
Thu Apr 24 15:51:22 CEST 2008


Christopher.White at bbh.com wrote:
> 
> Ceki,
> 
> I do understand your reasoning, and thank you for your quick response.
> 
> And since Logback natively implements SLF4J, its API will also not be 
> changed to include any new JSE 5 features, correct? Nor will new method 
> signatures specific to just Logback be created for this (if I chose to 
> use Logback without SLF4J)?

Correct. As you stated, the logback API sits on top of SLF4J. There are no plans 
to change that.

> This is unfortunate for those who have been using JSE 5 for some time 
> now, and still have not been able to fully take advantage of its 
> features (especially when it comes to the work of tedious logging).

You do realize that the SLF4J API already supports parameterized logging up to 2 
parameters? With an SLF4J logger you can write:

Logger logger = LoggerFactory.getLogger(Wombat.class);
Integer t;
Integer oldT;
Integer expectedT;

logger.debug("Some message.");
logger.debug("Temperature set to {}", t);
logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);

However, SLF4J does not support 3 or more parameters. So, you could not write:

logger.debug("new={}, old={}, expected={}", t, oldT, expectedT);

You would have to write:

logger.debug("new={}, old={}, expected={}", new Integer[] {t, oldT, expectedT});

I believe that compared to the slight inconvenience above, breaking 
compatibility is a more serious concern.


> I was really excited about SLF4J/Logback when this project started, but 
> without these new features (which would simplify and reduce my coding 
> effort) it just doesn't seem worth it to convert to this logging 
> framework (even though I really appreciate the clean Logback 
> implementation). Perhaps Log4J 2.0 will incorporate these considerations 
> since it will be JSE 5 dependent. If it does, I'd have to bet that many 
> people will jump ship on SLF4J/Logback in favor of Log4J. It really is 
> too bad that the Logback API cannot be changed before it reaches version 
> 1.0.

You might also want to check out the slf4j-migrator [1] which may help with your 
migration efforts, when and if you decide to migrate to SLF4J.

[1] http://slf4j.org/migrator.html

-- 
Ceki Gülcü
QOS.ch is looking to hire talented developers in Switzerland.  If
interested, please contact c e k i AT q o s . c h




More information about the slf4j-user mailing list