
Thanks for the pointer Lutz, I definitely would have missed that even if I had gone into the Javadocs because that tip is buried in the section under the default constructor. After reading other posts, it seems that this is a bug that affects logback 1.0.0. When I downgraded to version 0.9.30, things worked as expected and I was able to send SSL mail through Gmail. Thanks, Alex 2012/3/3 Lutz Hühnken <lh.logback.list@googlemail.com>
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@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@gmail.com</username> <password>somepass</password> <to>someone@gmail.com</to> <from>somebody@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@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
-- Alexander Glass AGS Consulting (917) 670 7506 www.ags-consulting.net