Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j - SMTPAppender

 
kaparapu madhu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I executed the following code, it is not throwing any exceptions but the mail is not being sent
=====================================
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.net.SMTPAppender;
public class SmtpLogger {
public static Logger logger = Logger.getLogger(SmtpLogger.class);
public static void main(String args[]){
logger.setLevel(Level.ERROR);
SMTPAppender smtpapp = null;
try{
smtpapp = new SMTPAppender();

smtpapp.setFrom("madhukumar@symbiosys.com");
smtpapp.setTo("jagadish@symbiosys.com");
smtpapp.setSubject("Fatal Error information....");
smtpapp.setBufferSize(1);
smtpapp.setSMTPHost("192.168.100.111");

logger.addAppender(smtpapp);
logger.error("Hai this is error");
logger.fatal("hai this is fatal");
}catch(Exception ex){
ex.printStackTrace();
}
}
}
=============================================================
so please suggest me how to post fatal errors using SMTPAppender
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic