Log4J: Most commonly used logger. Very well tested over time and has lots of features.
Logback: Successor of Log4J. It is better than Log4J because:
It is claimed to be ten times faster than Logback.
Much better filtering capabilities (example: conditional filtering in production systems).
Can separate logs from each user to different files by using a new appender called ‘Sifting Appender’
Includes package version information in stack traces.
Java.util.logging: This is natively implemented inside Java but has less features than log4J.
Intended to be used for simple logging only.
TinyLog: Extremely simple and twice as fast as log4j.
Unlike any other logger, it shows improves performance in multi-threading.
SLF4J (Simple Logging Façade): Allows any logger to be plugged into a Java application at the time of deployment.
This is done by selecting the respective binder-library.
For example, if log4j is desired to be used, then slf4j-log4j12-1.7.5.jar can be used to bind the same during deployment and so on.
Jakarta Commons Logging: JCL is also a façade over logging implementations like SLF4J but it is not as good as SLF4J.
Log4jdbc: This is a logger developed by google.
It uses SLF4J and substitutes question marks in SQL queries with actual values to make them more readable in the logs.
It also prints timing information for each query.
Finally, the best combination to go for big production systems is
Logback + SLF4J and
Log4jdbc + SLF4J
For small projects, Java.util.logging is ideal.
Got a thought to share or found a bug in the code? We'd love to hear from you: