Regarding the problem of springboot printing logs twice

1. The source of the problem

    When I started the project, I found that the project started very slowly. It was like a thousand years later. I was helpless. I checked the log carefully. Amei, the log was printed repeatedly. As shown in the figure below, I was surprised and not surprised. . . . . . . . . .

 2. Solution

  1. Prioritize package conflicts or package duplication issues, and find that there is no difference from the introduction of other projects, so exclude them.

  2. Consider the level problems introduced by the project structure. The basic package of the main project structure is quoted. Considering whether the same startup category is repeatedly introduced, it is excluded after investigation.

  3. Consider the log output, look at the log framework introduced by the project, and find that the configuration of logback-spring.xml is used, and combined with the information on the Internet, locate the configuration of logback-spring.xml. The following is the configuration method:

Adjusted configuration parameters:

Reason: The log configuration before adjustment will be executed regardless of whether it is in the console mode or the ordinary log mode, causing the log to be output twice. The log level here: INFO; after the adjustment, according to your own scenario, do not choose the console output , pay attention to the log Level, additivity="false" .

4. Check whether the dependent environment increases hot deployment (on the Internet, the original poster is caused by the log configuration), and then remove:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
</dependency>

3. Information

  1. Technology stack configuration based on springboot

  2. Log configuration and reference materials:

https://www.cnblogs.com/zhangjianbing/p/8992897.html

https://www.jianshu.com/p/6f093b0b0c8a

https://www.cnblogs.com/ifenwang/p/7068689.html

Guess you like

Origin blog.csdn.net/baidu_28068985/article/details/109531547