Loading...
пʼятниця, 11 квітня 2014 р.

logback e-mail appender example

An example for logback email appender (logback SMTP appender) configuration. Short description for some elements: 
  • filter is for sending ERROR level e-mails only even if root logger level is set to different value.
  • ${logback.smtp.something} variables should be defined in some property file
  • bufferSize variable is for maximum number of e-mails sent for error. I.e if this value is 1 and two exceptions exist in the application flow, only the last one will be messaged


<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
    <filter class="ch.qos.logback.classic.filter.LevelFilter">
        <level>ERROR</level>
        <onMatch>ACCEPT</onMatch>
        <onMismatch>DENY</onMismatch>
    </filter>

    <smtpHost>${logback.smtp.host}</smtpHost>
    <smtpPort>${logback.smtp.port}</smtpPort>
    <SSL>${logback.smtp.ssl}</SSL>
    <username>${logback.smtp.username}</username>
    <password>${logback.smtp.password}</password>
    <to>${logback.smtp.to.address}</to>
    <from>${logback.smtp.from.address}</from>

    <subject>${logback.smtp.subject}</subject>
    <asynchronousSending>false</asynchronousSending>
    

<layout class="ch.qos.logback.classic.html.HTMLLayout">
        <pattern>
            %d%t%-55logger{55}%m
        </pattern>

    </layout>

    <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker">
        <bufferSize>
            5
        </bufferSize>

    </cyclicBufferTracker>

</appender>

0 коментарі:

 
TOP