mybatis-Spring boot 集成Mybatis怎么在控制台打印sql语句
1个回答
展开全部
一、需要mybatis和log4j的jar;
二、然后在log4j.properties文件里面将下面的代码粘贴进去就可以了:
版本一:
[java] view plain copy
<span style="font-size:12px;">log4j.rootLogger=DEBUG, Console
#Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG</span>
版本二:
[java] view plain copy
<span style="font-size:12px;">log4j.rootLogger = ${log.level},Console,default,allfile
log4j.logger.com.ibatis=debug
log4j.logger.java.sql=debug
log4j.logger.com.sf.egmas.dcn.web.mapper=debug</span>
二、然后在log4j.properties文件里面将下面的代码粘贴进去就可以了:
版本一:
[java] view plain copy
<span style="font-size:12px;">log4j.rootLogger=DEBUG, Console
#Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG</span>
版本二:
[java] view plain copy
<span style="font-size:12px;">log4j.rootLogger = ${log.level},Console,default,allfile
log4j.logger.com.ibatis=debug
log4j.logger.java.sql=debug
log4j.logger.com.sf.egmas.dcn.web.mapper=debug</span>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询