This is an AMP version of the article, its original content can be found here.
Get Rid of Java Static Loggers
This is a very common practice in Java
What's wrong with it? Code duplication.
LOGGER property has to be declared in every class
where logging is required. Just a few lines of code, but
this is pure noise, as I see it.
To make life easier, I created a library about two years
ago, jcabi-log, which has a convenient
(yes, I know that utility classes are evil).
This looks much cleaner to me and does exactly
the same—sends a single log line to the SLF4J
logging facility. Besides, it check automatically whether a given logging
level is enabled (for performance optimization) and formats the
given string using
For convenience, there are also a number of "decors" implemented in the library.
The library ships as a JAR dependency in Maven Central (get its latest versions in Maven Central):