Why log

For program development, it is often necessary to write print statements to test the running results, and then delete print statements after the development, which is cumbersome and highly intrusive. Instead, we use logging.

Why Logback

Logging can be done in a variety of ways, including JDK Logging, or JUL, which comes with the java.util package. There are also third-party log libraries. The early use of third-party Logging libraries was Commons Logging + Log4j, and the trend is SLF4J + Logback. SLF4J provides a Logging interface similar to Commons Logging; Logback provides an implementation of the logging interface, similar to Log4j.

Unhappy with the Commons Logging interface, someone decided to use SLF4J. Because someone wasn’t satisfied with Log4j’s performance, Logback was created.

How do I use Logback

There is no need to write anything about Lockback in Java code, just configure its XML file. SLF4j can automatically use Lockback by simply writing SLF4j content in Java code. Detailed XML configuration methods will be presented in the next article.