One option would be to have separate loggers per form and then only attach the appender to the desired logggers. Note that SMTPAppender only sends email when it encounters and error (or higher) level logger..
On 3/27/07, tyson magney <[EMAIL PROTECTED]> wrote:
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
-- James Stauffer http://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]