Hi,
in case an error occurs in my Application an eMail should be generated and
sent to administrator.
In the unlikely case that our primary mail server cannot be reached, the
mail should be sent via our backup-mailserver.
But if log4J cannot reach the primary one an error is thrown, but this
error is not passed back to my application so i can't react on it, but
instead only printed into the console.
My code looks like this ...

try
{
      logger = Logger.getLogger(MailManager.class);
      MyLogger.init("log4j.xml");

      SimpleLayout layout = new SimpleLayout();
      SMTPAppender appender = null;
      appender = new SMTPAppender();

      appender.setTo("[EMAIL PROTECTED]");
      appender.setFrom("[EMAIL PROTECTED]");
      appender.setSubject("Error occured");
      appender.setSMTPHost("192.168.90.93");
      appender.setBufferSize(1);
      appender.setLayout(layout);
      appender.activateOptions();

      logger.addAppender(appender);
      logger.error(myException.getMessage());
}
catch(Exception exc)
{
      System.err.println("!!!! Exception caught !!!!");
}
catch(Error err)
{
      System.err.println("!!!! Error caught !!!!");
}

But neither exception nor error is caught by my application, do i have to
rewrite any log4j-native classes ???

Thanks
Dirk



--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@;jakarta.apache.org>

Reply via email to