I have an electronic forms processing application that releases documents to
a database.  When an exception occurs, the app needs to send an email to an
admin depending on which form threw the exception.  I already have lo4j in
place with an SMTP appender configured.  What I cannot figure out is, how do
I conditionaly send emails?  I could setup multiple SMTP appenders, but how
would log4j know which appender to use when a particular form throws an
exception?

The best solution I can come up with, is to subclass SMTPAppender and
override sendBuffer().  When sendBuffer is called, the appender name would
be compared to a value stored in the MDC. If a match  is found then
super.sendBuffer would be called.  Cany anyone think of a better solution?

Thanks.

- Tyson

Reply via email to