displaying MyBatis SQL statements through the LOG4J debug level

Source: Internet
Author: User
Tags log4j

To make it easier to debug SQL statements, you need to display MyBatis SQL statements.

The general approach on the Web is achieved through log4j, but many of them are problematic.

After the experiment, the following code can be kept normal: (only display the debug statement of the MyBatis SQL statement, the other debug does not display)

Log4j.rootlogger = DEBUG, Console,logfile,errorfile #注意这里需要改成DEBUG

# Apply to Console
Log4j.appender.CONSOLE = Org.apache.log4j.ConsoleAppender
Log4j.appender.CONSOLE.Threshold =DEBUG #注意这里需要改成DEBUG
Log4j.appender.CONSOLE.Target = System.out
Log4j.appender.CONSOLE.layout = Org.apache.log4j.PatternLayout
Log4j.appender.CONSOLE.layout.ConversionPattern ==standard%d{yyyy-mm-dd hh:mm:ss,sss}%p%l-%m%n

#重点:

# # #显示SQL语句部分
# #将不需要DEBUG的信息级别提高,
Log4j.logger.org.springframework=warn #代表以org. Springframework the beginning of the log is displayed according to the WARN level
Log4j.logger.org.apache.ibatis=warn
Log4j.logger.org.mybatis.spring=warn
Log4j.logger.com.mchange=warn
#将需要显示的信息的日志降低
Log4j.logger.org.apache.ibatis.logging=debug

Ps:

The path in the logger suffix can be customized as needed.

displaying MyBatis SQL statements through the LOG4J debug level

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.