#http://logging.apache.org/log4j/1.2/manual.html
#http://logging.apache.org/log4j/1.2/apidocs/index.html
#DEBUG < INFO < WARN < ERROR < FATAL
#日志输出路径
log4j.logSaveDir=logs
#开启log4j配置时的debug
log4j.debug=true
#顶级Logger
log4j.rootLogger=DEBUG,Console
#,File,DailyRollingFile,RollingFile,Mail,Socket,DataBase,MyLogger
#设置slf4j.log4j包下日志级别,及Logger
log4j.logger.slf4j.log4j=DEBUG,MyLogger
#是否在slf4j.log4j配置的logger输出后,再启用上级logger进行输出
log4j.additivity.slf4j.log4j=false
#设置slf4j.log4j2包下日志级别
log4j.logger.slf4j.log4j2=info
#全局日志级别过滤器
log4j.threshold=DEBUG
log4j.appender.MyLogger=org.apache.log4j.ConsoleAppender
log4j.appender.MyLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.MyLogger.layout.ConversionPattern=[%t] %d{yyyy-MM-dd HH:mm:ss,SSS} [%r] [%-5p] [%c{2}] - [%m] [%l]%n
log4j.appender.MyLogger.Threshold=DEBUG
#log4j.appender.MyLogger.filter.DenyAll=org.apache.log4j.varia.DenyAllFilter
#ConsoleAppender - 控制台
log4j.logger.Console=DEBUG
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%t] %d{yyyy-MM-dd HH:mm:ss,SSS} [%r] [%-5p] [%c{2}] - [%m] [%l]%n
log4j.appender.Console.Threshold=DEBUG
#Filter↓↓↓
#DenyAllFilter 过滤掉所有
#LevelMatchFilter 日志匹配过滤
#LevelRangeFilter 日志区间过滤,区间外的首先会被过滤掉(LevelRangeFilter.decide),区间内的即使AcceptOnMatch为true,也返回Filter.NEUTRAL
#StringMatchFilter 将message与指定字符串匹配(只是简单的包含匹配,不支持正则啊,有需要的自己扩展下)
#log4j.appender.Console.filter.DenyAll=org.apache.log4j.varia.DenyAllFilter
#log4j.appender.Console.filter.LevelMatch=org.apache.log4j.varia.LevelMatchFilter
#log4j.appender.Console.filter.LevelMatch.LevelToMatch=ERROR
#log4j.appender.Console.filter.LevelMatch.AcceptOnMatch=false
#log4j.appender.Console.filter.StringMatch=org.apache.log4j.varia.StringMatchFilter
#log4j.appender.Console.filter.StringMatch.StringToMatch=hello
#log4j.appender.Console.filter.StringMatch.AcceptOnMatch=false
#log4j.appender.Console.filter.MyFilter=slf4j.log4j.MyFilter
#Filter↑↑↑
#FileAppender - 文件
log4j.appender.File=org.apache.log4j.FileAppender
log4j.appender.File.File=${log4j.logSaveDir}/log4j_FileAppender.log
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=[%t] %d{yyyy-MM-dd HH:mm:ss,SSS} [%r] [%-5p] [%c{2}] - [%m] [%l]%n
#DailyRollingFileAppender - 每天一个日志文件,在每日结束时将日志文件重命名
log4j.appender.DailyRollingFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DailyRollingFile.File=${log4j.logSaveDir}/log4j_DailyRollingFileAppender.log
log4j.appender.DailyRollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.DailyRollingFile.layout.ConversionPattern=[%t] %d{yyyy-MM-dd HH:mm:ss,SSS} [%r] [%-5p] [%c{2}] - [%m] [%l]%n
log4j.appender.DailyRollingFile.DatePattern="'-'yyyy-MM-dd"
#RollingFileAppender - 大小到达指定尺寸的时候新建日志文件
log4j.appender.RollingFile=org.apache.log4j.RollingFileAppender
log4j.appender.RollingFile.File=${log4j.logSaveDir}/log4j_RollingFileAppender.log
log4j.appender.RollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingFile.layout.ConversionPattern=[%t] %d{yyyy-MM-dd HH:mm:ss,SSS} [%r] [%-5p] [%c{2}] - [%m] [%l]%n
log4j.appender.RollingFile.MaxBackupIndex=3
log4j.appender.RollingFile.MaxFileSize=2kb
#SocketAppender - Socket
log4j.appender.Socket=org.apache.log4j.net.SocketAppender
log4j.appender.Socket.layout=org.apache.log4j.PatternLayout
log4j.appender.Socket.layout.ConversionPattern=[%t] %d{yyyy-MM-dd HH:mm:ss,SSS} [%r] [%-5p] [%c{2}] - [%m] [%l]%n
#SMTPAppender - 邮件
log4j.appender.Mail=org.apache.log4j.net.SMTPAppender
log4j.appender.Mail.Threshold=DEBUG
log4j.appender.Mail.BufferSize=10
log4j.appender.Mail.SMTPHost=smtp.163.com
log4j.appender.Mail.SMTPPassword=yourMailPassword
log4j.appender.Mail.SMTPDebug=true
log4j.appender.Mail.Subject= log4J Message
log4j.appender.Mail.layout=org.apache.log4j.PatternLayout
log4j.appender.Mail.layout.ConversionPattern=[%t] %d{yyyy-MM-dd HH:mm:ss,SSS} [%r] [%-5p] [%c{2}] - [%m] [%l]%n
#JDBCAppender - 数据库
log4j.appender.DataBase.Threshold=DEBUG
log4j.appender.DataBase.DEBUG=true
log4j.appender.DataBase=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.DataBase.URL=jdbc:mysql://localhost:3306/test
log4j.appender.DataBase.driver=com.mysql.jdbc.Driver
log4j.appender.DataBase.user=root
log4j.appender.DataBase.password=123
log4j.appender.DataBase.sql=INSERT INTO log4j_log(message) VALUES('[%t] %d{yyyy-MM-dd HH:mm:ss,SSS} [%r] [%-5p] [%c{2}] - [%m] [%l]')
log4j.appender.DataBase.layout=org.apache.log4j.PatternLayout
#建表语句
#CREATE TABLE `log4j_log` (`message` VARCHAR(512) NULL);
#未避免输出每条日志都要连接一次数据库,建议重写JDBCAppender