Hi Sushil,

As far as I know there is no such log4j feature
as you describe in your email.

If you want to implement it, here is a suggestion
about how I would do it (no promises this is the
best way!).

I would create a new Filter class which keeps a
FIFO queue of references to the last N messages
which passed through it (a suitable value for N 
might be 10). For any message, if a "matching"
message is in the queue, and that matching
message's timestamp is within your timelimit
then the filter returns DENY to avoid logging
the message, else it adds the message to its
queue (possibly pushing an old message off
the other end of the queue) and returns ACCEPT.

This filter could then be applied to any Appender
you like (though you will need to use xml config
files for log4j, as property-based config files
don't currently support filters.

You can find a few example filters in the standard
distributions.

I think creating this filter will take only a few hours
[depending on familiarity with the existing log4j code].

Regards,

Simon

> -----Original Message-----
> From: Sureka, Sushil [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, February 20, 2001 10:04 PM
> To:   '[EMAIL PROTECTED]'
> Subject:      creating filter based on time interval
> 
> Hi folks,
> 
> We have a need in our project for the following
> 
> If a program logs two simillar messages within a time frame of <x
> milliseconds>, the logger should discard the second message. The reason
> being is that in the past, due to a programming error (excption occured in
> the while loop), the program logged around 10,000 messages to NT event
> Logger noting the exception and as a result, it really affected all other
> server resources.
> 
> I looked around in log4J document but I could not find any. 
> 
> Any help would be appreciated
> Sushil
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to