I've worked out a simple extension to the SMTPAppender and I'm wondering if it's worth contributing back to log4j and how one might do that. I named the class "GatedSMTPAppender" (in a separate namespace). By default it doesn't send email based on logging events. An external process can get a reference to the appender by looking it up through the root logger and then invoking a method which sends and email of all events in the circular buffer. I wrote a very small JBoss service using the JBoss scheduler class that works very well for this in a JBoss environment.

Effectively this lets me have log4j events emailed out on a timed basis. I use an initial setting of 15 minutes for the JBoss service. What prompted me to do this was an experience I had recently where other developers released code onto a JBoss server that I monitor. They broke the installation which resulted in an "ERROR" level message getting emailed to me every 5 to 10 seconds for a span about 3 days while I was on vacation. I'm embarrassed to say that I had to clean out a little over 40,000 emails from my Inbox when I returned to work. Queuing that amount of log events into emails that get sent every 15 minutes or so is something I can better handle. If the circular buffer wraps around due to an overload, so be it - the email is just a "heads up" anyway that something needs attention.

Does this sound worthwhile enough to contribute back?

Best regards,
Lance
http://www.newparticles.com/

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



Reply via email to