Introduction
Logging is a common issue for most development teams. There have been several frameworks developed to ease and standardize the process of logging for the Java platform. This page covers general purpose logging frameworks. There are other logging frameworks, toolkits and libraries like Tracing Class Loader but that is for another topic.
Comparing Features
Feature | Log4J | Java Logging API | Jakarta Commons Logging |
Supported log levels | FATAL ERROR WARN INFO DEBUG TRACE | SEVERE WARNING INFO CONFIG FINE FINER FINEST | FATAL ERROR WARN INFO DEBUG TRACE |
Standard Appenders | AsyncAppender, JDBCAppender, JMSAppender, LF5Appender, NTEventLogAppender, NullAppender, SMTPAppender, SocketAppender, SocketHubAppender, SyslogAppender, TelnetAppender, WriterAppender | ConsoleHandler, FileHandler, SocketHandler, MemoryHandler | Depends on the underlying framework |
Popularity[citation needed] | Widely used in many project and platforms | few | many, in conjunction with log4j |
Cost/Licence | Apache License, Version 2.0 | Comes with the JRE | Apache License, Version 2.0 |
Summary
Of the major players, log4j is still the front runner in the Java Logging ___domain. The log4j project has been around for a long time and has lots of support from the development community. It's simple to implement, yet has powerful tools built in to accomplish most logging tasks. It is also easily extensible to handle proprietary needs.
The newer logging API, which has been included in the JRE since 1.4, incorporates many of the same concepts as log4j. It has loggers and appenders. However, log4j has been much more broadly used and there are many out-of-the-box solutions in log4j that are lacking in the Java Logging API.[citation needed]
The Jakarta Commons Logging isn't really a logging framework, but a logging framework wrapper. As such, it requires a logging framework underneath it. It would be useful in an heterogeneous environment where the logging framework is likely to change. However, in most cases, once a suitable logging framework has been chosen, there is little need to change it over the life of the project.
Links to Java Logging Projects
- Java 1.4 Logging API
- Java 6.0 Logging API (presently same document as 1.4 above, but with Java 6 links)
- Commons Logging
- Log4j
- Protomatter
- The Object Guy's Logging Framework
See also:
- Open Source Logging Tools in Java
- Logging in Java Applications article by Thornton Rose