logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Repeat ignores messages
Date Sat, 28 Jan 2006 10:33:54 GMT
On Fri, 27 Jan 2006, Ron Grabowski <rongrabowski@yahoo.com> wrote:

> Do you want to keep a count of every unique log message and append
> that to the message?

I guess, neither of both.  It is a handy feture of some logging
packages (Linux version of syslog for example) to batch up consecutive
unique messages.  In your example

> 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");

The output would be exactly the same with and without batching, but 

log.Debug("A");
log.Debug("AB");
log.Debug("ABC");
log.Debug("ABCD");
log.Debug("A");
log.Debug("A");
log.Debug("A");
log.Debug("AB");

would lead to 

A
AB
ABC
ABCD
A
last message repeated two times
AB

If you want to get fancy you'd make that "twice" instead of "two
times".

I've once done something similar for an in-house (Java) logging
framework in a past job.  The way I implemented it would translate
into an appender that was a decorator around another appender which
just keeps track of the last message it logged, the memory overhead is
minimal.  In addition I had a thread that made sure log statements
were not delayed, so if the last AB log never happened a trigger would
cause the "last message repeated two times" after some time.

Stefan

Mime
View raw message