logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S K <gridsngat...@gmail.com>
Subject Re: Problem in using SMTPAppender with gmail
Date Fri, 12 Dec 2008 22:09:32 GMT
Hello All,

I am trying out a simple application to test log4j to send out email
through gmail. I have followed the instructions by VMMM. So this is
how my code looks:

public class LogCheck {

      private static Logger log;
      public static void main(String args[]) {
         System.setProperty("mail.smtps.host", "smtp.gmail.com");
         System.setProperty("mail.smtps.auth", "true");
         System.setProperty("mail.debug", "true");

         log = Logger.getLogger(LogCheck.class);
         log.info("This is an info log ");
         log.error("This is an error log ");
         System.out.println("Done!");
      }
}

The contents of my log4j properties file:

log4j.rootCategory=DEBUG, R, M
log4j.logger.org.apache=OFF, R, M

log4j.appender.M=org.apache.log4j.net.SMTPAppender
log4j.appender.M.Threshold=INFO
log4j.appender.M.SMTPHost=smtp.gmail.com
log4j.appender.mail.SMTPUsername=****
log4j.appender.mail.SMTPPassword=****
log4j.appender.M.Subject=Log4j error
log4j.appender.M.From=****@gmail.com
log4j.appender.M.To=****@gmail.com
log4j.appender.M.layout=org.apache.log4j.PatternLayout
log4j.appender.M.layout.ConversionPattern=Date  : %d{DATE}%n\
Level : %p%nThread: %t%nClass : %c%nLine  : %l%n\
Message: %m%n%n

Contents of the javamail.address.map file:
rfc822=smtps

When I run the code I get the following error:

DEBUG: JavaMail version 1.4.1
DEBUG: not loading file: /local/.../jre/lib/javamail.providers
DEBUG: java.io.FileNotFoundException: /local/.../jre/lib/
javamail.providers (No such file or directory)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/
javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name:
{com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider
[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems,
Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider
[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems,
Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider
[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc],
com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider
[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc],
com.sun.mail.imap.IMAPStore=javax.mail.Provider
[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc],
com.sun.mail.pop3.POP3Store=javax.mail.Provider
[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider
[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc],
imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
Microsystems, Inc], smtps=javax.mail.Provider
[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems,
Inc], pop3=javax.mail.Provider
[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc],
pop3s=javax.mail.Provider
[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc],
smtp=javax.mail.Provider
[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/
javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: successfully loaded file: /local/.../jre/lib/javamail.address.map
DEBUG: getProvider() returning javax.mail.Provider
[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems,
Inc]
DEBUG SMTP: useEhlo true, useAuth true
log4j:ERROR Error occured while sending e-mail notification.
javax.mail.AuthenticationFailedException
          at javax.mail.Service.connect(Service.java:319)
          at javax.mail.Service.connect(Service.java:169)
          at javax.mail.Service.connect(Service.java:118)
          at javax.mail.Transport.send0(Transport.java:188)
          at javax.mail.Transport.send(Transport.java:118)
          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 LogCheck.main(LogCheck.java:18)
Done!

It would be great if any of you could provide me with any clues on
what could be happening here.

I am sure the authentication information is correct, since I have
checked that out many times.

Thank you.

-SK


---------------------------------------------------------------------
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