logback 설정 오류 메일 보내기

2492 단어 logbackSMTPAppender
logback을 설정하여 지정한 메일박스에 오류 레벨 로그를 보내려면jar 패키지를 가져와야 합니다:janino.jar

    <property name="smtpHost" value="smtp.163.com" />
    <property name="smtpPort" value="25" />
    <property name="username" value="[email protected]" />
    <property name="password" value="xxx" />
    <property name="SSL" value="false" />
    <property name="email_to" value="EMAIL-DESTINATION,ANOTHER_EMAIL_DESTINATION" />
    <property name="email_from" value="[email protected]" />
    <property name="email_subject" value="【Error】: %logger" />

	<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
		<smtpHost>${smtpHost}</smtpHost>
		<smtpPort>${smtpPort}</smtpPort>
		<username>${username}</username>
		<password>${password}</password>
		<SSL>${SSL}</SSL>
		<asynchronousSending>false</asynchronousSending>
		<to>${email_to}</to>
		<from>${email_from}</from>
		<subject>${email_subject}</subject>
		<layout class="ch.qos.logback.classic.html.HTMLLayout" >
			<pattern>%date%level%thread%logger{0}%line%message</pattern>
		</layout>
        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">  
            <evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator">
                <expression>
                	<!-- & encoded as &amp; -->
                	if(level > WARN &amp;&amp; null != throwable) {
                		return true;
                	}
                	return false;
                </expression>  
            </evaluator>  
            <onMatch>ACCEPT</onMatch>  
            <onMismatch>DENY</onMismatch>    
        </filter>
</appender>
<root level="INFO">
     <appender-ref ref="EMAIL"/>
</root>

공식 문서:http://logback.qos.ch/manual/appenders.html

좋은 웹페이지 즐겨찾기