Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Disclaimer</strong>: I am the founder of log4j, SLF4J and logback projects. </p> <p>There are objective reasons for preferring SLF4J. For one, it grants the end-user the liberty to choose the underlying logging framework. In addition, savvier users tend to prefer <a href="http://logback.qos.ch/reasonsToSwitch.html" rel="noreferrer">logback which offers capabilities beyond log4j</a>, with j.u.l falling way behind. Feature-wise j.u.l may be sufficient for some users but for many others it just isn't. In a nutshell, if logging is important to you, you would want to use SLF4J with logback as the underlying implementation. If logging is unimportant, j.u.l is fine.</p> <p>However, as an oss developer, you need to take into account the preferences of your users and not just your own. It follows that you should adopt SLF4J not because <em>you</em> are convinced that SLF4J is better than j.u.l but because most Java developers currently (July 2012) prefer SLF4J as their logging API. If ultimately you decide not to care about popular opinion, consider the following facts:</p> <ol> <li>those who prefer j.u.l do so out of convenience because j.u.l is bundled with the JDK. To my knowledge there are no other objective arguments in favor of j.u.l.</li> <li>your own preference for j.u.l is just that, <em>a preference</em>.</li> </ol> <p>Thus, holding "hard facts" above public opinion, while seemingly brave, is a logical fallacy in this case.</p> <p>If still not convinced, <a href="https://stackoverflow.com/users/571407/jb-nizet">JB Nizet</a> makes an additional and potent argument:</p> <blockquote> <p>Except the end user could have already done this customization for his own code, or another library that uses log4j or logback. j.u.l is extensible, but having to extend logback, j.u.l, log4j and God only knows which other logging framework because he uses four libraries that use four different logging frameworks is cumbersome. By using SLF4J, you allow him to configure the logging frameworks he wants, not the one you have chosen. <strong>Remember that a typical project uses myriads of libraries, and not just yours</strong>.</p> </blockquote> <p>If for whatever reason you hate the SLF4J API and using it will snuff the fun out of your work, then by all means go for j.u.l. After all, there are means to <a href="http://www.slf4j.org/legacy.html#jul-to-slf4j" rel="noreferrer">redirect j.u.l to SLF4J</a>.</p> <p>By the way, j.u.l parametrization is at least 10 times slower than SLF4J's which ends up making a noticeable difference.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload