You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ken Arnold <ar...@moonhill.org> on 2002/08/07 05:34:07 UTC

circular buffering

I need a circular buffered appender -- one that tracks the last N 
messages so when something goes wrong I can dump out those.  The idea is 
that the circular buffer can take debug-level messages, but you don't 
see them until there is a problem, when only the N most recent ones are 
likely to be valuable.

Has anyone already done this?  I've started to code this up, and run in 
to the interesting problem of how to get my hands on these appenders to 
flush them when that's needed.  (I'm assuming here that they are created 
from configuration, not explicitly in code.)  The best I can figure out 
is a static call that is given one logger, and then scrounges through 
the tree finding and flushing these buffering appenders.  (I'm walking 
up the tree from the logger looking for appenders until either I hit the 
top or something that isn't additive; then  because I can't figure out 
how to walk down the three I'm looking through all the loggers for those 
that are descended from the specified logger without an intervening 
non-additive logger.  This means that flushing from the root gets all 
loggers not blocked by non-additives, for example.)

Any thoughts are welcome.  I will obviously post the thing when I'm done 
in case anyone else wants it.

		Ken


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: circular buffering (attached)

Posted by Ken Arnold <ar...@moonhill.org>.
On Wednesday, August 7, 2002, at 04:46  PM, Ceki Gülcü wrote:

>
> I'll be on vacation for two weeks so I can't give feedback until then. 
> Anyone else care to study to comment?

If anyone tries it, do me the favor of using the attached version of 
BufferingAppender.  There was a bug in the initial one that dealt 
improperly with partly filled buffers (I was more worried about overflow 
so I kept testing that -- classic example of why one really can't QA 
their own code reliably).

		Ken Arnold



Re: circular buffering (attached)

Posted by Ceki Gülcü <ce...@qos.ch>.
I'll be on vacation for two weeks so I can't give feedback until then. 
Anyone else care to study to comment?

At 16:35 07.08.2002 -0400, you wrote:

>On Wednesday, August 7, 2002, at 04:31  PM, Ken Arnold wrote:
>
>>I've attached the files that I wrote.  I've assumed that finding all 
>>loggers that are associated with a given node is a useful feature, so I 
>>did it using a vistor pattern.  This is meant to be integrated into the 
>>codebase should the owners find that useful, so I've given it the Apache 
>>header.
>>
>>                 Ken
>
>My mailer's "Send" button is right next to it's "Attach" button, and so I 
>hit "send" by mistake too early.  Here are all the files.  The XML file is 
>a simple tester for BufferingAppender.
>
>Feedback, bug rep0rts, and chocolate all welcome.-)

--
Ceki


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: circular buffering (attached)

Posted by Ken Arnold <ar...@moonhill.org>.
On Wednesday, August 7, 2002, at 04:31  PM, Ken Arnold wrote:

> I've attached the files that I wrote.  I've assumed that finding all 
> loggers that are associated with a given node is a useful feature, so I 
> did it using a vistor pattern.  This is meant to be integrated into the 
> codebase should the owners find that useful, so I've given it the 
> Apache header.
>
> 		Ken

My mailer's "Send" button is right next to it's "Attach" button, and so 
I hit "send" by mistake too early.  Here are all the files.  The XML 
file is a simple tester for BufferingAppender.

Feedback, bug rep0rts, and chocolate all welcome.-)


Re: circular buffering (attached)

Posted by Ken Arnold <ar...@moonhill.org>.
I've attached the files that I wrote.  I've assumed that finding all 
loggers that are associated with a given node is a useful feature, so I 
did it using a vistor pattern.  This is meant to be integrated into the 
codebase should the owners find that useful, so I've given it the Apache 
header.

		Ken


Re: circular buffering

Posted by Ken Arnold <ar...@moonhill.org>.
On Wednesday, August 7, 2002, at 03:20  AM, Ceki Gülcü wrote:

> Have you seen SMTPAppender? It is based on a circular buffer.

Okay, SMTPAppender triggers on particular logging events, with an 
arbitrary TriggeringEventEvaluator
object to know when to flush.  This seems reasonable in the normal 
case -- when a warning occurs, say, let me know what's been happening 
recently.

There are a couple of difficulties.  First, as far as I can tell, there 
are no existing objects that implement the interface, so there is no way 
to use a configurator to attach a trigger for (say) a particular event 
level.  Obviously I can solve this writing my own code, which I'm doing 
anyway.  This sounds like a job for a class that will trigger on either 
events with a minimum priority or any of a set of messages.

The harder thing is that it still will only apply to buffering appenders 
attached to the logger that generates the event.  When something goes 
wrong I know which logger services the class that suffered the 
consequences, but I don't know which subsystem was having troubles that 
may have caused the problem.  So I would like to be able to flush 
everyone, or at least everyone in a particular name region (com.acme.*).

Maybe this is generally useful and I should write a class with methods 
that give you a visitor pattern for walking through all appenders in a 
subtree.

I will rework what I've done so that it could properly be a superclass 
for SMTPAppender should that prove useful.  Thanks for the pointer.

		Ken


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: circular buffering

Posted by Ken Arnold <ar...@moonhill.org>.
On Wednesday, August 7, 2002, at 03:20  AM, Ceki Gülcü wrote:

> Have you seen SMTPAppender? It is based on a circular buffer.

I hadn't noticed that it was, since I hadn't been interested in SMTP as 
such.  I will look there for clues.

		Ken


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: circular buffering

Posted by Ceki Gülcü <ce...@qos.ch>.
Have you seen SMTPAppender? It is based on a circular buffer.

At 23:34 06.08.2002 -0400, you wrote:
>I need a circular buffered appender -- one that tracks the last N messages 
>so when something goes wrong I can dump out those.  The idea is that the 
>circular buffer can take debug-level messages, but you don't see them 
>until there is a problem, when only the N most recent ones are likely to 
>be valuable.
>
>Has anyone already done this?  I've started to code this up, and run in to 
>the interesting problem of how to get my hands on these appenders to flush 
>them when that's needed.  (I'm assuming here that they are created from 
>configuration, not explicitly in code.)  The best I can figure out is a 
>static call that is given one logger, and then scrounges through the tree 
>finding and flushing these buffering appenders.  (I'm walking up the tree 
>from the logger looking for appenders until either I hit the top or 
>something that isn't additive; then  because I can't figure out how to 
>walk down the three I'm looking through all the loggers for those that are 
>descended from the specified logger without an intervening non-additive 
>logger.  This means that flushing from the root gets all loggers not 
>blocked by non-additives, for example.)
>
>Any thoughts are welcome.  I will obviously post the thing when I'm done 
>in case anyone else wants it.
>
>                 Ken

--
Ceki


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>