转自:https://blog.csdn.net/rocklee/article/details/90675601
log4j.logger.druid.sql.Statement=DEBUG,logsql
#普通sql不要显示在console
log4j.additivity.logsql=false
log4j.appender.logsql=org.apache.log4j.FileAppender
log4j.appender.logsql.layout=org.apache.log4j.PatternLayout
log4j.appender.logsql.File=${catalina.home}/logs/pms/sql.log
log4j.appender.logsql.DatePattern='.'yyyy-MM-dd
log4j.appender.logsql.ImmediateFlush=false
log4j.appender.logsql.MaxFileSize=10MB
#输出文件最大序号为10
log4j.appender.logsql.MaxBackupIndex=10
log4j.appender.logsql.BufferedIO=true
#500K
log4j.appender.logsql.BufferSize=512000
log4j.appender.logsql.Append=true
log4j.appender.logsql.layout.ConversionPattern=[%d{MM-dd HH\:mm\:ss}] %c{1} - %m%n
log4j.logger.com.alibaba.druid.filter.stat=ERROR,slowsql
log4j.appender.slowsql=org.apache.log4j.FileAppender
log4j.appender.slowsql.layout=org.apache.log4j.PatternLayout
log4j.appender.slowsql.File=${catalina.home}/logs/pms/slow_sql.log
log4j.appender.slowsql.DatePattern='.'yyyy-MM-dd
log4j.appender.slowsql.ImmediateFlush=true
log4j.appender.slowsql.Append=true
log4j.appender.slowsql.Threshold=ERROR
log4j.appender.slowsql.layout.ConversionPattern=[%d{MM-dd HH\:mm\:ss}] %c{1} - %m%n