Log framework: Provides an interface for calling logs. The actual log output is delegated to the log system for implementation.
- JCL (Jakarta Commons Logging): a popular log framework, many of which depend on JCL, such as Spring.
- SLF4j: provides new APIs. It was originally used with Logback but is also compatible with Log4j.
Log System: Outputs logs.
- Log4j: an earlier log system that can be used independently or with the log framework JCL.
- Logback: an alternative to Log4j, which must be used with the log framework SLF4j
- JUL (java. util. logging): the log system provided by JDK is chaotic and not commonly used.
Log System usage
Log framework |
Log System |
Description |
-- |
Log4j |
Log4j can be used independently, not recommended |
JCL |
Log4j |
Use log4j with JCL |
SLF4j |
Logback |
Use logback with SLF4j |
SLF4j |
SLF4j-Log4j12 + log4j |
Log4j works with SLF4j, but uses SLF4j-Log4j12 for bridging |
Server Load balancer + JCL-over-SLF4j |
Logback |
Enable the system using JCL + log4j to use logback to output logs. |
Server Load balancer + JCL-over-SLF4j |
SLF4j-log4j12 + Log4j |
The framework uses SLF4j, but logs use Log4j and are compatible with the original JCL interface. This method is mostly due to complex package dependencies, and each package uses different log frameworks. |
SLF4j + JCL-over-SLF4j + log4j-over-slf4j |
SLF4j-log4j12 + log4j |
In addition, it is compatible with scenarios where some packages use log4j directly. |
Description
- JCL-over-SLF4j is a compatible framework that is compatible with the JCL interface and uses the SLF4j log framework, dependent on SLF4j, but cannot coexist with JCL
- SLF4j-Log4j12 is a compatible framework to make Log4j work in the SLF4j environment. It is the same as logback as a log system and cannot coexist.
- Log4j-over-slf4j is used to use the SLF4j framework and is compatible with the use of log4j directly