You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by B Reed <bi...@gmail.com> on 2007/09/05 16:58:19 UTC

Log4j SMTPAppender Exception

Hi,
I have a properties file set up to email me errors. I see errors in my web
application log file, but apparently log4j cannot successfully email them to
me. Then I see the exception below in my tomcat server log file.

I am able to send emails from this web application, just not when via log4j
errors.

Any help is appreciated! Thanks.

Here is the exception on my tomcat server log file:

log4j:ERROR Error occured while sending e-mail notification.
javax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
        javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security
.provider.certpath.SunCertPathBuilderException: unable to find valid
certification path to requested target
        at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java
:1420)
        at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java
:1408)
        at com.sun.mail.smtp.SMTPTransport.simpleCommand (SMTPTransport.java
:1394)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(
SMTPTransport.java:407)
        at javax.mail.Service.connect(Service.java:297)
        at javax.mail.Service.connect(Service.java :156)
        at javax.mail.Service.connect(Service.java:105)
        at javax.mail.Transport.send0(Transport.java:168)
        at javax.mail.Transport.send(Transport.java:98)
        at org.apache.log4j.net.SMTPAppender.sendBuffer (Unknown Source)
        at org.apache.log4j.net.SMTPAppender.append(Unknown Source)
        at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java
:230)
        at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders (
AppenderAttachableImpl.java:65)
        at org.apache.log4j.Category.callAppenders(Category.java:203)
        at org.apache.log4j.Category.forcedLog(Category.java:388)
        at org.apache.log4j.Category.error( Category.java:302)



Here is my log4j.properties:

log4j.rootLogger=WARN, R, mail
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/MyApplication.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=100
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %5p [%c] %n%m%n
#---------------------------------------------------------------------#
# The following emails errors and fatal messages
#---------------------------------------------------------------------#
log4j.appender.mail=org.apache.log4j.net.SMTPAppender
#defines how often emails are send
log4j.appender.mail.BufferSize=1
log4j.appender.mail.SMTPHost=<smtp.hostname>
log4j.appender.mail.From=<email address>
log4j.appender.mail.To=<email address>
log4j.appender.mail.Subject=" Application.log error occurred"
log4j.appender.mail.threshold=ERROR
log4j.appender.mail.layout=org.apache.log4j.PatternLayout
log4j.appender.mail.SMTPUsername=<username>
log4j.appender.mail.SMTPPassword= <password>
log4j.appender.mail.layout.ConversionPattern=%d %5p [%c] %n%m%n

Re: Log4j SMTPAppender Exception

Posted by Curt Arnold <ca...@apache.org>.
On Sep 5, 2007, at 9:58 AM, B Reed wrote:

> Hi,
> I have a properties file set up to email me errors. I see errors in  
> my web
> application log file, but apparently log4j cannot successfully  
> email them to
> me. Then I see the exception below in my tomcat server log file.
>
> I am able to send emails from this web application, just not when  
> via log4j
> errors.
>
> Any help is appreciated! Thanks.
>
> Here is the exception on my tomcat server log file:
>
> log4j:ERROR Error occured while sending e-mail notification.
> javax.mail.MessagingException: Can't send command to SMTP host;
>   nested exception is:
>         javax.net.ssl.SSLHandshakeException:
> sun.security.validator.ValidatorException: PKIX path building failed:
> sun.security
> .provider.certpath.SunCertPathBuilderException: unable to find valid
> certification path to requested target
>         at com.sun.mail.smtp.SMTPTransport.sendCommand 
> (SMTPTransport.java
> :1420)
>         at com.sun.mail.smtp.SMTPTransport.sendCommand 
> (SMTPTransport.java
> :1408)
>         at com.sun.mail.smtp.SMTPTransport.simpleCommand  
> (SMTPTransport.java
> :1394)
>         at com.sun.mail.smtp.SMTPTransport.protocolConnect(
> SMTPTransport.java:407)
>         at javax.mail.Service.connect(Service.java:297)
>



Possibly your SMTP server has a test or invalid certificate, see  
http://blogs.sun.com/andreas/entry/no_more_unable_to_find.   
Definitely seems like a problem in the javamail level and not in  
log4j.  log4j makes the proper request, javamail throws an exception  
and log4j does the best it can with the exception.



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