首页 > 代码库 > logback配置错误邮件发送
logback配置错误邮件发送
配置logback发送error级别日志到指定邮箱
需要导入jar包:janino.jar
1 <property name="smtpHost" value="http://www.mamicode.com/smtp.163.com" /> 2 <property name="smtpPort" value="http://www.mamicode.com/25" /> 3 <property name="username" value="http://www.mamicode.com/xxx@163.com" /> 4 <property name="password" value="http://www.mamicode.com/xxx" /> 5 <property name="SSL" value="http://www.mamicode.com/false" /> 6 <property name="email_to" value="http://www.mamicode.com/EMAIL-DESTINATION,ANOTHER_EMAIL_DESTINATION" /> 7 <property name="email_from" value="http://www.mamicode.com/xxx@163.com" /> 8 <property name="email_subject" value="http://www.mamicode.com/【Error】: %logger" /> 9 10 <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> 11 <smtpHost>${smtpHost}</smtpHost> 12 <smtpPort>${smtpPort}</smtpPort> 13 <username>${username}</username> 14 <password>${password}</password> 15 <SSL>${SSL}</SSL> 16 <asynchronousSending>false</asynchronousSending> 17 <to>${email_to}</to> 18 <from>${email_from}</from> 19 <subject>${email_subject}</subject> 20 <layout class="ch.qos.logback.classic.html.HTMLLayout" > 21 <pattern>%date%level%thread%logger{0}%line%message</pattern> 22 </layout> 23 <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> 24 <evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator"> 25 <expression> 26 <!-- & encoded as & --> 27 if(level > WARN && null != throwable) { 28 return true; 29 } 30 return false; 31 </expression> 32 </evaluator> 33 <onMatch>ACCEPT</onMatch> 34 <onMismatch>DENY</onMismatch> 35 </filter> 36 </appender> 37 <root level="INFO"> 38 <appender-ref ref="EMAIL"/> 39 </root>
转自:http://superich2008.iteye.com/blog/2070388
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。