码迷,mamicode.com
首页 > 其他好文 > 详细

log4j.properties

时间:2015-09-20 17:52:29      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

#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.debug=true

log4j.rootLogger=DEBUG,Console

log4j.logSaveDir=logs

#,File,DailyRollingFile,RollingFile,Mail,Socket,DataBase


#ConsoleAppender - 控制台

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



#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.From=yourMailAccount@163.com

log4j.appender.Mail.SMTPHost=smtp.163.com

log4j.appender.Mail.SMTPUsername=yourMailAccount@163.com

log4j.appender.Mail.SMTPPassword=yourMailPassword

log4j.appender.Mail.SMTPDebug=true

log4j.appender.Mail.Subject= log4J Message

log4j.appender.Mail.Bcc=anotherMailAccount@qq.com

log4j.appender.Mail.To=anotherMailAccount@qq.com

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);

#未避免insert一条就链接一次数据库,建议重写JDBCAppender


#level指大于该级别的日志才显示, error>warn>info>debug

#threshold起过滤作用,即低于过滤条件的日志不显示


log4j.properties

标签:

原文地址:http://my.oschina.net/moxun/blog/508757

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!