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

logback配置错误邮件发送

时间:2014-07-09 17:30:23      阅读:1595      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   os   

配置logback发送error级别日志到指定邮箱 

需要导入jar包:janino.jar 

 
 1 <property name="smtpHost" value="smtp.163.com" />  
 2     <property name="smtpPort" value="25" />  
 3     <property name="username" value="xxx@163.com" />  
 4     <property name="password" value="xxx" />  
 5     <property name="SSL" value="false" />  
 6     <property name="email_to" value="EMAIL-DESTINATION,ANOTHER_EMAIL_DESTINATION" />  
 7     <property name="email_from" value="xxx@163.com" />  
 8     <property name="email_subject" value="【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 &amp; -->  
27                     if(level > WARN &amp;&amp; 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

logback配置错误邮件发送,布布扣,bubuko.com

logback配置错误邮件发送

标签:des   style   blog   http   color   os   

原文地址:http://www.cnblogs.com/fanelephant/p/3831964.html

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