用log4j发错误日志到邮箱 log配置文件: log4j.rootLogger=INFO, A1 ,MAIL #A1:输出到控制台 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n #MAIL:发送到邮件 log4j.appender.MAIL=org.apache.log4j.net.SMTPAppender log4j.appender.MAIL.Threshold=ERROR log4j.appender.MAIL.BufferSize=10 log4j.appender.MAIL.From=usename@163.com log4j.appender.MAIL.SMTPHost=smtp.163.com log4j.appender.MAIL.SMTPUsername=usename@163.com log4j.appender.MAIL.SMTPPassword=password log4j.appender.MAIL.SMTPDebug=false log4j.appender.MAIL.To=rusename@163.com log4j.appender.MAIL.Subject=Log4J\u63d0\u9192\u60a8\uff1a\u7cfb\u7edf\u53d1\u751f\u4e86\u4e25\u91cd\u9519\u8bef #国际化转换了,邮件标题不是乱码 log4j.appender.MAIL.layout=org.apache.log4j.PatternLayout #log4j.appender.MAIL.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n #log4j.appender.MAIL.layout.ConversionPattern=[ErrorMessage] %d - %c -%-4r [%t] %-5p %c %x - %m%n #log4j.appender.MAIL.layout=org.apache.log4j.HTMLLayout log4j.appender.MAIL.layout=examples.net.stmp.DefineLayOut #处理了乱码的layout log4j.appender.MAIL.layout.LocationInfo=true 日志输出类StmpAppenders : package examples.net.stmp; 乱码处理类: DefineLayOut: |