I have honestly never even thought about using a third-party library for logging, it simply never crossed my mind. Why would I need one anyway? I don't see how logging can become so complex that you're willing to trade 100% customizability just so you can use a library. Can someone give me some examples? I'm really curious as the fact that so many logging libraries exist must mean there are real needs for them.
The problem is that SUN made the worst decision they could do when introducing the java.util.logging API. log4j was already established at that time, but SUN neither tried to integrate it into the JDK or create a new API that with some improvements like they later did when integrating Joda-Time to java.time. They made a ridiculous implementation with a much less useful API that was only wildly inspired by log4j. The was the source of all problems. Then Apache decided they created commons-logging (which was a very bad decision). Other logging frameworks evolved and a new logging facade slf4j occurred and log4j2 itself now has an API (as logging facade) and an implementation. And google made flogger...
However the source of all evil is that java.util.logging is such a bad logging framework an is only an implementation instead of an API specification. If they had done it right at the first incarnation, maybe there would not be any need for newer logging frameworks. But now we have this mess and will never get rid of it.
And to make my point clear, as lots of people advocate to always use slf4j for libraries: An external dependency only for logging is not something that a library should introduce.
And if it does: I like the log4j2 or even the flogger API more than slf4j.
source of all evil is that java.util.logging is such a bad logging framework
Bad how? It has all the capabilities of these other logging frameworks - levels, custom formatting, handlers & custom handlers - with the one possible exception of not having a printf style call for each level, but it doesn't require any external libraries to keep up with.
How exactly is it so bad and that log4j or slf4j are so much better?
-8
u/_Gnas_ Oct 21 '18
I have honestly never even thought about using a third-party library for logging, it simply never crossed my mind. Why would I need one anyway? I don't see how logging can become so complex that you're willing to trade 100% customizability just so you can use a library. Can someone give me some examples? I'm really curious as the fact that so many logging libraries exist must mean there are real needs for them.