Hi Matthias, I would suggest to write your own appender that extends SMTPAppender and implements the desired logic of gathering related log messages, and sends them out when an error is received.
You'd probably want to implement some mechanism that restricts the amount of context that is retained, to make sure you don't hog memory and don't send out massive emails in case it takes very long for an error to occur. Alternatively (and mind you, I can only guess what you're really after, so this may not be applicable at all to your situation), if there are only very specific circumstances where you want to collect only a very specific combination of logging events, you may want to consider whether you are looking in the correct place for a solution. Maybe, it's more practical (and more "correct") to combine the information from these logging events in a single event, basically for the same reason that you shouldn't spread a multi-line log text over several log calls, but rather collect them in a single log call (separate log calls may end up arbitrarily distant from eachother in log files, (viewers, etc., ) depending on what else is logging to the same log - i.e. if something logically belongs together, you should put it together in a single log event). Practically, this would translate into logic that says, issue an INFO level log event when everything is OK, but issue an ERROR level log event when something is up, which not only includes a statement that says something is wrong, but also includes the information that you would otherwise have sent in the INFO event). Just something to ponder, maybe you prefer the solution of an extension of SMTPAppender that keeps some context. Regards, Eelke -----Original Message----- From: Matthias Petersen [mailto:[EMAIL PROTECTED] Sent: dinsdag 19 december 2006 11:01 To: log4j-user@logging.apache.org Subject: How to get all logging in the case of an error ? Hi, I have the following configuration: ConsoleAppender for INFO and ERROR SMTP-Appender for ERROR The problem is that I want to send a mail with the SMTP-Appender with all logging events in the case of an error, because when an errors occurs the INFO events contain additional informations (e.g. command line parameters of the application). But I can't configure the SMTP-Appender for the additional INFO events because I want to receive the mail only in the case of an error. No Error: No Mail Error: Mail including INFO and ERROR Has anybody a good idea for this problem ? Bye, Matthias -- ms management systems gmbh Krokamp 29, 24539 Neumünster Fon : 04321.9995-49 Fax : 04321.9995-41 E-Mail : [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]