The logback log does not print out the package conflict solution

Problem Description

During the development of the web application, it was found that the application log deployed in the server suddenly disappeared. Only the restart log of tomcat or jboss was printed in the server, but the log file set by the application itself was not printed.

problem analysis

The application branch has just been checked from the trunk, and the trunk branch is normal after it is deployed on the server. All log files and log information in the files can be printed and displayed normally.

According to previous experience, it is judged that the application deployment is successful, and the new code submitted only introduces a new dependency package in the pom file of the maven project. It is initially suspected that the logback package conflict is caused by the newly introduced package.

solution

The number of dependencies of the maven project is printed out through the mvn dependency command, and there are indeed two different versions of logback references.

Use the exclusion command to exclude low-version logback packages. The reference example is as follows:

 

<exclusions>
  <exclusion>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
  </exclusion>
</exclusions>

 It is mainly caused by the package conflict of logback-classic. After the unique version is confirmed, the application is redeployed, and the log is successfully printed.

summary of a problem

At first I thought it was caused by the log4j package conflict, but the result of the investigation turned out to be a logback package problem. I didn't know the difference between the two before. After this problem investigation, I also learned this knowledge by the way:

Introduction to logback

LogBack is divided into 3 components, logback-core, logback-classic and logback-access. in

logback-core provides the core functions of LogBack and is the basis for the other two components;

logback-classic implements the API of Slf4j, so when you want to use it with Slf4j, you need to add logback-classic to the classpath;

logback-access is prepared for integrating with the Servlet environment and can provide a log interface for HTTP-access.

Because logback has unparalleled advantages in technical implementation and performance, logback is generally used now, and log4j is slowly replaced.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326897600&siteId=291194637