logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken....@bmwna.com
Subject RE: suppressing duplicates
Date Fri, 02 Apr 2004 15:48:10 GMT
Hi Jeff -

I had previously answered this question - have a look at my response below.

Ken

> -----Original Message-----
> From: Jeff Drew [mailto:jeffdrew@tradingmetrics.com]
> Sent: Thursday, April 01, 2004 11:54 AM
> To: log4j-user@logging.apache.org
> Subject: suppressing duplicates

> Does log4j have the ability to suppress duplicates?  Not the 
> duplication caused by root loggers and descendants.  I know 
> that is alleviated by 
> with the additivity setting.  


-----Original Message-----
From: Ken.Liu@bmwna.com [mailto:Ken.Liu@bmwna.com]
Sent: Wednesday, December 17, 2003 11:34 AM
To: log4j-user@jakarta.apache.org
Subject: RE: How to detect duplicate messages in log4j


There isn't an API where you can access a set of previous messages.

However, Ceki describes a good approach in his book.

You can create a Filter that hangs on to the previous LogEvent and
suppresses an incoming LogEvent if it is a duplicate.  There is nothing to
prevent you from buffering n number of messages (SMTPAppender does this),
although you would need to probably hold on to a queue of unique messages if
the duplicate messages aren't being logged one after another. 

I think this approach is more flexible than subclassing appender because you
can attach the filter to any appender.

Ken

> -----Original Message-----
> From: Shubhra [mailto:shubhrad@momentum-tech.com]
> Sent: Wednesday, December 17, 2003 7:45 AM
> To: log4j-user@jakarta.apache.org
> Subject: How to detect duplicate messages in log4j
> 
> 
> Hi All,
> I have a client that sends a heartbeat to the server every 30 
> seconds. If
> the client is unable to connect to the server it prints the 
> message along
> with the stack trace. This failure may persist for a while 
> and there is a
> risk of filling up the log files. If I just note the failure, 
> there is a
> risk of not being able to fully diagnose a problem later on.
> 
> I want to detect repetitive error logging and instead log just a note
> summarizing the failure *AFTER* the first error logging (with 
> the failure
> reported in its entirety).
> 
> To implement the above, I plan to create my own Appender that extends
> RollingFileAppender and overwrites subAppend(LoggingEvent 
> event) . For a
> duplicate message create a new LoggingEvent with Throwable 
> null else proceed
> with original LoggingEvent.
> 
> The problem is how to determine if a message is a duplicate?
> Is there any API that lets me read all the events that have 
> occurred in last
> 30 seconds, whereby I can do the comparison and leave out 
> stack trace of
> duplicate messages.
> 
> Regards,
> Shubhra
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 

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

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


Mime
View raw message