Log4j配置错误日志邮件发送
我们项目中log4j为我们输出很多错误日志,由于没有及时处理,造成系统运行不稳定,所以可以将错误日志通过邮件形式发送给具体开发人员
1.配置log4j.properties
#DEV log4j.rootLogger =DEBUG,stdout #RUNING #log4j.rootLogger =INFO,I,E,A5 # Console output... log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target = System.out log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}||%F||%M||%m%n # INFO log4j.appender.I =org.apache.log4j.DailyRollingFileAppender log4j.appender.I.File =/home/logs/info.log log4j.appender.I.Append =true log4j.appender.I.Threshold =info log4j.appender.I.layout =org.apache.log4j.PatternLayout log4j.appender.I.layout.ConversionPattern =%d{yyyy-MM-dd HH:mm:ss}||%F||%M||%m%n # ERROR log4j.appender.E =org.apache.log4j.DailyRollingFileAppender log4j.appender.E.File =/home/logs/error.log log4j.appender.E.Append =true log4j.appender.E.Threshold =error log4j.appender.E.layout =org.apache.log4j.PatternLayout log4j.appender.E.layout.ConversionPattern =%d{yyyy-MM-dd HH:mm:ss} %m%n #EMAIL log4j.appender.A5=org.apache.log4j.net.SMTPAppender log4j.appender.A5.BufferSize=5 log4j.appender.A5.Threshold=error log4j.appender.A5.To=[被发送者] log4j.appender.A5.From=[发送者] log4j.appender.A5.Subject=ErrorLog log4j.appender.A5.SMTPHost=[STMP服务] log4j.appender.A5.SMTPUsername=[用户名] log4j.appender.A5.SMTPPassword=[密码] log4j.appender.A5.layout=org.apache.log4j.PatternLayout log4j.appender.A5.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
来自:http://my.oschina.net/guoenzhou/blog/526626
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!