参考http://www.iteye.com/topic/378077
http://blog.csdn.net/anlina_1984/article/details/5313023/
log4j主要使用的jar包
commons-logging-1.1.jar,log4j-1.2.17.jar,slf4j-api-1.7.5.jar,slf4j-log4j12-1.7.5.jar
配置文件
log4j.rootLogger=info, Console, MyFile
#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
#MyFile
log4j.appender.MyFile=org.apache.log4j.FileAppender
log4j.appender.MyFile.File=D:/logs/myfile.log
log4j.appender.MyFile.layout=org.apache.log4j.PatternLayout
log4j.appender.MyFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
###显示mybatis的sql语句log配置
log4j.rootLogger=DEBUG, Console, MyFile
#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
#MyFile
log4j.appender.MyFile=org.apache.log4j.FileAppender
log4j.appender.MyFile.File=D:/logs/myfile.log
log4j.appender.MyFile.layout=org.apache.log4j.PatternLayout
log4j.appender.MyFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
###sql statement
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.Java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.org.apache=INFO
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
###追加
org.springframework=DEGUG
com.opensymphony=DEBUG