MyBatis配置log4j输出日志

阅读更多

# This is the configuring for logging displayed in the Application Server;delete ,stdout
log4j.rootCategory=INFO,stdout,R

# Replace the line above if you want to put a log file into the directory
# you start Tomcat from
# log4j.rootCategory=INFO, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=[你的日志文件名]%d{ISO8601}- %p [%t] %c{1}.%M(%L) | %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender

# You can change this to be an absolute path or even an environment variable
# If you're using an environment variable, you will have to set JAVA_OPTS
# to contain this variables - for example in the catalina.sh or catalina.bat
# file

log4j.appender.R.File=${webapp.root}/logs/日志文件名.log
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout

log4j.appender.R.MaxFileSize=500KB

# Don't keep a backup file
log4j.appender.R.MaxBackupIndex=10

log4j.appender.R.layout=org.apache.log4j.PatternLayout
#log4j.appender.R.layout.ConversionPattern=%d{ISO8601} - %p %t [%C{1}] - %m%n
log4j.appender.R.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=error

log4j.logger.org.springframework.beans.factory.xml.XmlBeanDefinitionReader=DEBUG
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.mapper包的路径,如com.iccc.mapper=DEBUG,CONSOLE
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.java.sql.ResultSet =DEBUG

 

在MyEclipse控制台就可以打印出sql及参数信息,亲测成功!

 

你可能感兴趣的:(MyBatis配置log4j输出日志)