mybatis怎么在控制台打印sql语句
2017-11-07
展开全部
一、需要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>
版本三:
[java] view plain copy
<span style="font-size:12px;">log4j.rootLogger=info,debug,stdout,info,error
#ibatis logger config
log4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=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>
版本三:
[java] view plain copy
<span style="font-size:12px;">log4j.rootLogger=info,debug,stdout,info,error
#ibatis logger config
log4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=debug</span>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
一、需要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>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询