logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Problem in using SMTPAppender with gmail
Date Sat, 20 Sep 2008 02:08:28 GMT

On Sep 19, 2008, at 6:30 AM, Virajith KHP wrote:

> Hello,
>
> I'm using Log4j as the logging framework and I've configured it to  
> send an
> email with log information when a log with ERROR/FATAL logging level  
> is
> created.My Log4j configuration is as follows.
>
>
>    code:
>
>
>     <appender  name="smtp_ErrorFatal"
> class="org.apache.log4j.net.SMTPAppender" >
>            <param name="SMTPHost" value="smtp.gmail.com" />
>            <param name="SMTPUsername" value="[username]" />
>            <param name="SMTPPassword" value="[password]" />
>            <param name="From" value="[valid email]" />
>            <param name="To" value="[valid email]" />
>            <param name="Cc" value="[valid email]" />
>            <param name="Subject" value="[LOG] ..." />
>            <param name="BufferSize" value="512" />
>            <param name="threshold" value="error" />
>            <layout class="org.apache.log4j.PatternLayout">
>                <param name="ConversionPattern" value="%d{DATE} |  
> %-5p |
> %X{userid} | %C | %M | %t | %L | %m%n" />
>            </layout>
>        </appender>
>
>
>
> But whenever a log with ERROR/FATAL logging level is created, Log4j  
> tries to
> send the email but terminates it with the following exception..
>
>    code:
>
>
>    log4j:ERROR Error occured while sending e-mail notification.
>    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a
> STARTTLS command first. a14sm1453665tia.0
>
>            at
> com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java: 
> 1388)
>            at
> com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
>            at
> com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
>            at javax.mail.Transport.send0(Transport.java:169)
>            at javax.mail.Transport.send(Transport.java:98)
>            at
> org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:330)
>            at
> org.apache.log4j.net.SMTPAppender.append(SMTPAppender.java:215)
>            at
> org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
>            at
> org 
> .apache 
> .log4j 
> .helpers 
> .AppenderAttachableImpl 
> .appendLoopOnAppenders(AppenderAttachableImpl.java:66)
>            at org.apache.log4j.Category.callAppenders(Category.java: 
> 206)
>            at org.apache.log4j.Category.forcedLog(Category.java:391)
>            at org.apache.log4j.Category.error(Category.java:305)
>            at
> miracle 
> .server 
> .presentation 
> .customcomponents.SplashFrame.retrieveSplashImage(SplashFrame.java:53)
>            at
> miracle 
> .server 
> .presentation.customcomponents.SplashFrame.<init>(SplashFrame.java:29)
>            at
> miracle.server.logic.common.AppManager$1.run(AppManager.java:41)
>            at java.awt.event.InvocationEvent.dispatch(Unknown Source)
>            at java.awt.EventQueue.dispatchEvent(Unknown Source)
>            at  
> java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
> Source)
>            at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown
> Source)
>            at  
> java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
> Source)
>            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>            at java.awt.EventDispatchThread.run(Unknown Source)
>
>
>
> Can anybody point out where the problem is?


The SMTPAppender has no explicit support for SMTP+SSL.  However the  
underlying JavaMail API does have support for SMTP+SSL and should be  
able to be coaxed into using it by setting system properties (adding  
the properties in the log4j.properties file would not be sufficient).

I believe the following set of properties:

mail.transport.protocol=smtps
mail.smtps.host=smtp.google.com
mail.smtps.auth=true

would be sufficient, but have not tried them.  There is a possibility  
that the site certificate would not be recognized as legit (unlikely  
for google, but more likely for internal mail servers).  There are  
notes on setting up your trust store to accept self-signed and other  
questionable certs in the JavaMail documentation.

There is an open bug to add support for SMTP+SSL to https://issues.apache.org/bugzilla/show_bug.cgi?id=25355

.  If the adhoc properties method works, then  I'd suggest adding a  
"protocol" property for SMTPAppender which would avoid any explicit  
support for encryption which could trigger export restrictions.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message