SpringMVC+ hibernate +Log4j+SLF4J is used in the application. Log4j's log level is set to INFO. However, when the web container (Tomcat) starts and runs , the DEBUG-level logs in the frameworks such as spring and Hibernate are constantly flushed, resulting in a sharp increase in log files and a disk explosion within a few days.
In response to this problem, I have found a lot of methods on the Internet, but they are all ineffective or can not cure the symptoms. I always thought there was something wrong with my Log4j configuration file. Later, in my newly built project, I found that the configuration of Log4j is correct. Only log information of INFO level and above is printed. Later I learned that it was because the jar that my application depended on implicitly depended on the logback logging framework.
Log4j and logback are conflicting, which will cause Log4j's log level to drop to DEBUG level. Knowing the reason, remove the implicit dependency of logback in the maven dependency. Then start tomcat and find that the log can be printed normally. How to remove dependencies:
<dependency>
<groupId>com.hoteam.df</groupId>
<artifactId>util-tools</artifactId>
<version>3.1.8</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
</exclusions>
</dependency>
The jar packages required by log4j+sjf4j include:
log4j-1.2.xx.jar
slf4j-api-x.x.x.jar
slf4j-log4j12-x.x.x.jar
The jar packages required by logback+sjf4j are:
logback-classic-0.9.21.jar
logback-core-0.9.21.jar
slf4j-api-1.6.x.jar