We use the token bucket filter for exactly this purpose. https://issues.apache.org/bugzilla/show_bug.cgi?id=45753
We adapted Chad LaVigne's to use for logback and it works well. IMO, a
TokenBucketFilter should ship with logback.
snipit from one of our xml configs:
<appender name="EMAIL"
class="com.emiles.util.log.logback.ReverseSMTPAppender">
<BufferSize>128</BufferSize>
<SMTPHost>...</SMTPHost>
<From>...</From>
<To>...</To>
<Subject>... %p %m%nopex</Subject>
<Evaluator class="com.emiles.util.log.logback.TokenBucketEvaluator">
<TokenFillAmount>2</TokenFillAmount>
<TokenFillInterval>300</TokenFillInterval>
<MaxTokens>20</MaxTokens>
<LogLevel>ERROR</LogLevel>
</Evaluator>
this will allow a burst of 20 emails followed by a gradual build up of letting
2 more through every 5 minutes.
-casey
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Louie Liu
Sent: Monday, June 01, 2009 11:13 PM
To: [email protected]
Subject: [SPAM] - [logback-user] Question - Email found in subject
We have the following use case and would like to know what is the best practice
in logback framework.
Basically, we are trying to use the SMTP logger appender to send alert email
when the erorr is occured. The issue is that we would like to generate a
summary messages (which including, for example, about 100 errors which occured
within the given time frame) and send only one email. The reason for it is to
reduce the number of email to avoid flush the email server.
Please let us know what is the best way to configure the logback to satisfy the
use case above.
Thanks a lot.
Louie
_______________________________________________
Logback-user mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-user
TokenBucketEvaluator.java
Description: TokenBucketEvaluator.java
TokenBucket.java
Description: TokenBucket.java
_______________________________________________ Logback-user mailing list [email protected] http://qos.ch/mailman/listinfo/logback-user
