> Hi guys,
> I am a newbie to log4j and looking how I can configure 
> log4j.xml to send an exception and its stack trace to an 
> email, as it happens using the SMTPEmailAppender. Ideally I 
> would like to control or configure the exception object that 
> would trigger an email (for ex: Send email for all exceptions 
> that extend certain xyz exception class)..Is this possible? 
> If not..what is closest thing that is possible without 
> extending or changing log4j original source code..
> Thanks
> Harsha

Yes this is possible.  You can set via configuration properties/xml on the
SMTPAppender the setEvaluatorClass property (so make sure you set the
"EvaluatorClass" property in the configuration), which takes a string of the
fully qualified name of a class that must implement the
org.apache.log4j.spi.TriggeringEventEvaluator interface.  You can then code
in your own class what will trigger the sending of the email.  

By default, the SMTPAppender installs a default TriggeringEventEvaluator
implementation that triggers on ERROR events, but you can do whatever you
like using your own impl of the interface.

Hope that helps.

cheers,

Paul Smith

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to