You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by L Nehring <ne...@newparticles.com> on 2004/11/24 00:59:46 UTC
Extension of SMTPAppender
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/
Re: Extension of SMTPAppender
Posted by Ceki Gülcü <ce...@qos.ch>.
Hello Lance,
Sounds like an experience to avoid. :-) Thank you for sharing your
thoughts with us.
I think the simplest way to avoid being swamped by a flood of error
reports is to place a leaky bucket in front of the
SMTPAppender. Basically, you don't need an external process to close
down the gates in case of a flood. SMTPAppender can handle this
itself.
Cheers,
At 12:59 AM 11/24/2004, L Nehring wrote:
>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/
>
--
Ceki Gülcü
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
IMAP appender?
Posted by None None <ja...@hotmail.com>.
I need to gaurantee that my e-mail was sent to the mail server. It seems as
if SMTP appender does not dtect errors.
So if my e-mail was not sent with the IMAP appender to fail over to file and
console or something like that!
Is there an IMAP appender?
Thanks
_________________________________________________________________
Powerful Parental Controls Let your child discover the best the Internet has
to offer.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSNŽ Premium right now and get the
first two months FREE*.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: Extension of SMTPAppender
Posted by None None <ja...@hotmail.com>.
I was looking through Jboss-4.0.0 log4j.xml config today. And I noticed an
error handler named OnlyOnceErrorHandler... Can this be a simpler solution
to your problem? Is the a new Jboss 4.0.0 feature or did log4j always
support it...
<appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Threshold" value="ERROR"/>
<param name="To" value="xxxxxxx"/>
<param name="From" value="JBoss"/>
<param name="Subject" value="JBoss Sever Errors"/>
<param name="SMTPHost" value="xxxxxx"/>
<param name="BufferSize" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
</layout>
</appender>
>From: L Nehring <ne...@newparticles.com>
>Reply-To: "Log4J Users List" <lo...@logging.apache.org>
>To: Log4J Users List <lo...@logging.apache.org>
>Subject: Extension of SMTPAppender
>Date: Tue, 23 Nov 2004 16:59:46 -0700
>
>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/
><< smime.p7s >>
_________________________________________________________________
Designer Mail isn't just fun to send, it's fun to receive. Use special
stationery, fonts and colors.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSNŽ Premium right now and get the
first two months FREE*.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org