Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A configuration for log4j properties. Be free to use it as a template and modify at will. Reference http://logging.apache.org/
#Log4J配置
#定义日志输出级别和输出流重定向
#修订历史:
# 2013-11-12 dylanninin@gmail.com init
log4j.rootLogger=CONSOLE,ROLLING_FILE,MAIL
log4j.addivity.org.apache=true
#####################################################################
#输出日志信息到控制台 级别INFO
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.Threshold=DEBUG
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
# %p 日志级别; %d 时间; %r 输出自应用启动到输出该log信息耗费的毫秒数;
# %t 线程名; %l ,包括类目名、发生的线程,以及在代码中的行数
# %m 输出代码中指定的消息,产生的日志具体信息
# %n 输出换行
log4j.appender.CONSOLE.layout.ConversionPattern=[SSH]%p %d %-4r [%t] %l - %m%n
#####################################################################
#####################################################################
#输出日志信息到回滚文件 级别ERROR
log4j.appender.ROLLING_FILE=org.apache.log4j.DailyRollingFileAppender
#日志记录级别
log4j.appender.ROLLING_FILE.Threshold=ERROR
#日志输出路径 webApp.SSH在web.xml中有定义
log4j.appender.ROLLING_FILE.File=${webApp.SSH}/WEB-INF/logs/error
#添加到原有日志末尾
log4j.appender.ROLLING_FILE.Append=true
#日志备份数
#log4j.appender.ROLLING_FILE.MaxBackupIndex=1
#回滚周期
log4j.appender.ROLLING_FILE.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.ROLLING_FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLING_FILE.layout.ConversionPattern=[SSH]%p %d %-4r [%t] %l - %m%n
#####################################################################
#####################################################################
#发送日志信息到邮箱 级别ERROR
log4j.appender.MAIL=org.apache.log4j.net.SMTPAppender
log4j.appender.MAIL.Threshold=ERROR
log4j.appender.MAIL.BufferSize=2048
log4j.appender.MAIL.From=SSHDev
log4j.appender.MAIL.SMTPHost=smtp.egolife.com
log4j.appender.MAIL.Subject=Log4J Error Message from SSH Application
log4j.appender.MAIL.To=dev@egolife.com
log4j.appender.MAIL.layout=org.apache.log4j.HTMLLayout
#log4j.appender.CONSOLE.layout.ConversionPattern=[SSH]%p %d %-4r [%t] %l - %m%n
#####################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.