You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by DB...@intersoft.de on 2002/11/12 12:27:04 UTC

SMTPAppender for prim. and sec. Mail-Servers

Hi,
i posted this message on the user-list, so if anyone got it twice, sorry
'bout that.

To my problem ...
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("bla@bla.bla");
      appender.setFrom("bla@bla.bla");
      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 ???
Noone on the user-mailing-list could help me with that, they said, it's
impossibe to catch errors, thrown in  the Appender-classes,
but errors should be thrown, so has anyone an idea how to solve this ??

Thanks
Dirk



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>