[logback-user] SMTP Appender silently fails

Alex Glass alexander.glass at gmail.com
Fri Mar 2 18:46:45 CET 2012


I'm trying to use SMTPAppender to send a log message through gmail.  I have
added javax.mail:mailapi:1.4.3 as a depdendency.  I also tried adding
javax.activation:activation:1.1.1 with no success.  If I change the host to
xyz, it has no affect.  This is my configuration file:

<configuration debug="true">
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>
                %-4relative [out] %-5level %logger - %msg%n
            </pattern>
        </encoder>
    </appender>

    <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
        <smtpHost>smtp.gmail.com</smtpHost>
        <smtpPort>465</smtpPort>
        <SSL>true</SSL>
        <username>somebody at gmail.com</username>
        <password>somepass</password>
        <to>someone at gmail.com</to>
        <from>somebody at gmail.com</from>
        <subject>Testing %logger{20} - %m</subject>

        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1} -
%msg%n</pattern>
        </layout>
    </appender>

    <root level="info">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="EMAIL" />
    </root>
</configuration>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Console output

12:45:56,627 |-INFO in ch.qos.logback.core.joran.action.AppenderAction -
About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
12:45:56,630 |-INFO in ch.qos.logback.core.joran.action.AppenderAction -
Naming appender as [STDOUT]
12:45:56,644 |-INFO in
ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default
type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder]
property
12:45:56,668 |-INFO in ch.qos.logback.core.joran.action.AppenderAction -
About to instantiate appender of type
[ch.qos.logback.classic.net.SMTPAppender]
12:45:56,678 |-INFO in ch.qos.logback.core.joran.action.AppenderAction -
Naming appender as [EMAIL]
12:45:56,714 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction
- Setting level of ROOT logger to INFO
12:45:56,714 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction -
Attaching appender named [STDOUT] to Logger[ROOT]
12:45:56,715 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction -
Attaching appender named [EMAIL] to Logger[ROOT]
12:45:56,715 |-INFO in
ch.qos.logback.classic.joran.action.ConfigurationAction - End of
configuration.

180  [out] INFO  SmtpTest - Hello World
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120302/c3788263/attachment.html>


More information about the Logback-user mailing list