You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Chad LaVigne <ch...@yahoo.com> on 2006/07/05 18:27:06 UTC

code contribution

Hello Log4j development team,
   
  My name is Chad LaVigne.  I would like to submit a filter I've written for consideration as an addition to the log4j project.  It is a filter that regulates bursts in logging using the Token Bucket algorithm.  It is useful in situations where you want to limit the number of log messages that can be generated in a certain time span.  This is often the case during a system failure type situation, you don't want to stop logging but you want to limit the number of messages that get logged to a reasonable amount.  This is how the filter works:
   
  The filter uses a token bucket object that contains a configurable number of tokens, specified by the filter init parameter maxTokens.  Every time a log statement is sent to an appender using this filter, the filter removes a token from the bucket. If no tokens are left in the bucket the log statement is suppressed. Tokens are added back to the bucket at a configurable rate that is calculated by two init parameters, tokenFillAmount and tokenFillInterval.  The number of tokens specified by tokenFillAmount are added every tokenFillInterval seconds up to the maximum number specified by maxTokens.
   
  I've attached the source code, a test class and a log4j configuration file that utilizes the filter.  Please let me know if you have any questions or comments.
 
Sincerely,
Chad LaVigne

 		
---------------------------------
Yahoo! Music Unlimited - Access over 1 million songs.Try it free. 

Re: code contribution

Posted by Chad LaVigne <ch...@yahoo.com>.
Thanks Elias, all good ideas.  I almost changed the name to exactly what you suggested.  The only reason I didn't was because I thought it made the init params and java doc a little more confusing since they refer to the token bucket and how it is used. Maybe we can come up with better names for the params too?
  
Elias Ross <er...@m-qube.com> wrote:
  
On Wed, 2006-07-05 at 09:27 -0700, Chad LaVigne wrote:
> I've attached the source code, a test class and a log4j configuration
> file that utilizes the filter. Please let me know if you have any
> questions or comments.

Just a couple of comments...

It might be nice to call it what it is used for, not how it was
implemented. I mean, "BurstFilter" or something describes what it does
a bit better.

Also, I think using "long" instead of "int" doesn't really make too much
sense. I don't see a case for over 4 billion tokens.

And I know this isn't directed at you, but it'd be nice to see something
similar to what Syslog does, which is suppresses duplicate messages,
then after some time displays a count of the number suppressed.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org



 		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

Re: code contribution

Posted by Elias Ross <er...@m-qube.com>.
On Wed, 2006-07-05 at 09:27 -0700, Chad LaVigne wrote:
> I've attached the source code, a test class and a log4j configuration
> file that utilizes the filter.  Please let me know if you have any
> questions or comments.

Just a couple of comments...

It might be nice to call it what it is used for, not how it was
implemented.  I mean, "BurstFilter" or something describes what it does
a bit better.

Also, I think using "long" instead of "int" doesn't really make too much
sense.  I don't see a case for over 4 billion tokens.

And I know this isn't directed at you, but it'd be nice to see something
similar to what Syslog does, which is suppresses duplicate messages,
then after some time displays a count of the number suppressed.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org