LOG4J configuration failure causes frames such as spring to print debug level logs

Source: Internet
Author: User
Tags log4j

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.