logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Venkat" <vadlamann...@yahoo.com>
Subject SMTP Gotchas
Date Wed, 16 Jul 2003 02:06:42 GMT
Hi, I was working on a project where Log4J is used for logging and wanted incorporate mailing
feature on errors using SMTPAppender.  In this process, I got stuck with some issues, on which
I could not find any useful info.  After a struggle for sometime, I was able to make it work
- and my pointers here may help those are in similar situation.

Log4J with SMTP prerequisites:

Classpath:  Make sure that activation.jar, maiapi.jar, smtp.jar are in classpath

            PatternLayout layout = new PatternLayout();
            SMTPAppender smtpa = new SMTPAppender();
            
            smtpa.setFrom("<from mail address>");
            smtpa.setTo("<to mail address>");
            smtpa.setSubject("<Your subject here>");
            smtpa.setSMTPHost("<SMTP Mail host name/ip>");
            
            smtpa.activateOptions();
            smtpa.setLayout(layout);
        
            logger.addAppender(smtpa);

upon the above, Log4J sends email on each error or fatal method calls.

Further, your smtp server should relay mails from your <from address>.  
Check 'relay' related information of your smtp server

--
Venkat
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message