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