jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes log4j - SMTPAppender Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "log4j - SMTPAppender" Watch "log4j - SMTPAppender" New topic
Author

log4j - SMTPAppender

kaparapu madhu
Greenhorn

Joined: Jun 13, 2005
Posts: 4
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j - SMTPAppender
 
Similar Threads
How to use log across objects
SMTPAppender problem while E-Mailing log file
Unable to set classpath for log4j
log4j:WARN No appenders could be found for logger (LogClass)
Log4j not working as expected with ejb module