[logback-user] SMTP Appender silently fails
Lutz Hühnken
lh.logback.list at googlemail.com
Sat Mar 3 13:22:24 CET 2012
Hi Alex,
although I am having issues with the SMTPAppender myself (as you
noticed - http://jira.qos.ch/browse/LBCLASSIC-323), you may be facing
something else here.
In your example, it seems the log event that you wish to trigger the
e-mail with ("SmtpTest - Hello World") has the level "INFO". Please
note (quote from the docs):
"By default, the email transmission is triggered by a logging event of
level ERROR. "
Log it as an error and see what happens.
If you wish to trigger mail for INFO events, you need to provide a
different "EventEvaluator". Go to
http://logback.qos.ch/manual/appenders.html and search for the section
with the headline "Triggering event" for details.
Hth,
Lutz
On Fri, Mar 2, 2012 at 6:46 PM, Alex Glass <alexander.glass at gmail.com> wrote:
>
> 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
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
More information about the Logback-user
mailing list