logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Repeat ignores messages
Date Sat, 28 Jan 2006 18:50:27 GMT
Here's a filter that ignores messages that contain the same exception
within a defined time period. For example if 500 identical log messages
are recieved within in 1 second time period only the first log message
is recorded:

http://tinyurl.com/cbq82
http://www.mail-archive.com/log4net-user%40logging.apache.org/msg02517.html

I understand how a simple counter variable could be used to keep track
of the number of repeated messages, but I still don't understand where
this log message will be generated:

 Last message was repeated 2 times.

When the timer inside the filter expires?

--- Morten Andersen <morten@vianett.no> wrote:

> Your code was not generating any repeated lines. A repeated line is
> only 
> true if the last logged line on the appender is the same. There
> should 
> be no memory issues because it is just a checksum of the last logged 
> line, and two datetime variables that is stored. One datetime for the
> 
> first, and one that changes every time the line is repeated. When a 
> different checksum occurs the last checksum, and the two datetime
> values 
> is replaced.
> 
> There should also be a timeout value. In my example I have a 10
> second 
> timeout.
> 
> Code:
> log.Debug("Hello world");
> log.Debug("Hello world");
> log.Debug("Hello world");
> Thread.Sleep(10500);
> log.Debug("Hello world");
> 
> Output:
> Hello world
> Last message was repeated 2 times.
> Hello world
> 
> - Morten
> 
> Ron Grabowski wrote:
> > Do you want to keep a count of every unique log message and append
> that
> > to the message?
> >
> > Code:
> > log.Debug("A");
> > log.Debug("AB");
> > log.Debug("ABC");
> > log.Debug("ABCD");
> > log.Debug("A");
> > log.Debug("AB");
> > log.Debug("ABC");
> > log.Debug("ABCD");
> > log.Debug("A");
> > log.Debug("AB");
> > log.Debug("ABC");
> > log.Debug("ABCD");
> >
> > Output:
> > A
> > AB
> > ABC
> > ABCD
> > A - repeated 2 times
> > AB - repeated 2 times
> > ABC - repeated 2 times
> > ABCD - repeated 2 times
> > A - repeated 3 times
> > AB - repeated 3 times
> > ABC - repeated 3 times
> > ABCD - repeated 3 times
> >
> > Or do you want to queue up repeated lines and output them when the
> > repository shuts down?
> >
> > A - repeated 3 times
> > AB - repeated 3 times
> > ABC - repeated 3 times
> > ABCD - repeated 3 times
> >
> > If you queue up repeated outputs not only will they potential take
> up a
> > lot of memory, but you'd loose all of the time stamp information
> > associated with a logging event.
> >
> > - Ron
> >   
> 


Mime
View raw message