【mybatis在控制台打印sql语句配置】
导入jar包:http://pan.baidu.com/s/1sl8RU37
<strong>#########################################################################
#Root Logger
#log4j.rootLogger = [ level ] , appenderName, appenderName,
#ConversionPattern:%d{yyyy-MM-dd-HH\:mm\:ss,SSS} [%t] [%c] [%p] - %m%n
#FilePath = /opt/uploads/maven_logs/maven_web.log
#########################################################################
#将 Mybatis log4j运行级别调到DEBUG可以在控制台打印出Mybatis运行的sql语句
log4j.rootLogger=DEBUG,Console,File
### 把日志信息输出到控制台 ###
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d{yyyy-MM-dd-HH\:mm\:ss,SSS} [%t] [%c] [%p] - %m%n
### 把日志信息输出到文件,项目所在的根目录:/opt/uploads/maven_logs/maven_web.log ######
log4j.appender.File = org.apache.log4j.DailyRollingFileAppender
log4j.appender.File.File = /opt/uploads/maven_logs/maven_web.log
log4j.appender.File.Threshold = DEBUG
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =%d{yyyy-MM-dd-HH\:mm\:ss,SSS} [%t] [%c] [%p] - %m%n
###显示SQL语句部分
log4j.logger.com.mybatis=DEBUG
log4j.logger.com.mybatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.mybatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.mybatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG</strong>