SPRINGMVC+HIBERNATE+LOG4J+SLF4J is used in the application. The log level of the log4j is tuned to info. However, when the Web container (Tomcat) starts and runs, the debug-level logs in the spring,hibernate frame are constantly being brushed, causing the log file to soar and the disk to explode in a few days.
In response to this problem on the Internet to find a lot of methods, are no effect or palliative treatment. Always thought your log4j configuration file was having problems writing. Later, in my new project, I found that the log4j configuration was correct. Only log information from info and above is printed. Later, it was because the jar on which its application depended implicitly relied on the Logback log framework.
Log4j and Logback are conflicting, which can cause the log4j log level to be lowered to the debug level. Knowing the reason, the implicit dependency of Logback is removed from maven dependency. Then start Tomcat and find that the logs are printed correctly. Ways 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
LOGBACK+SJF4J needs the jar package has
logback-classic-0.9.21.jar
&NBS P logback-core-0.9.21.jar
slf4j-api-1.6.x.jar