日志框架大致可以分为两类,一类是日志门面(Facade)(Apache Commons-logging 也被称作 Jakarta Commons-Logging(JCL)、slf4j、Log4j-api),定义日志的抽象接口;另一类是日志实现(JUL,log4j,log4j2,logback),负责真正地处理日志。

Log4j(Deprecated)

Legacy version of Log4J logging framework. Log4J 1 has reached its end of life and is no longer officially supported. It is recommended to migrate to Log4J 2.

Log4j2

Log4j2

Using Logback as an SLF4J Implementation

To start using the Logback, you need to add the logback-classic dependency to the classpath:

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.2.3</version>
</dependency>

This single dependency is enough, as it will transitively pull in the logback-core and slf4j-api dependencies.

If no custom configuration is defined, Logback provides a simple, automatic configuration on its own.  By default, this ensures that log statements are printed to the console at DEBUG level.

Lombok @Log (and friends)

@Log4j2

Creates private static final [org.apache.logging.log4j.Logger](<https://logging.apache.org/log4j/2.0/log4j-api/apidocs/org/apache/logging/log4j/Logger.html>) log = [org.apache.logging.log4j.LogManager.getLogger](<https://logging.apache.org/log4j/2.0/log4j-api/apidocs/org/apache/logging/log4j/LogManager.html#getLogger(java.lang.Class)>)(LogExample.class);

@Slf4j

Creates private static final [org.slf4j.Logger](<https://www.slf4j.org/api/org/slf4j/Logger.html>) log = [org.slf4j.LoggerFactory.getLogger](<https://www.slf4j.org/api/org/slf4j/LoggerFactory.html#getLogger(java.lang.Class)>)(LogExample.class);

Reference