logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spam2...@meeque.de
Subject Yet another Apender proposal: ListAppender
Date Fri, 15 Oct 2004 20:32:25 GMT
Hello folks!

Probably this is getting too frequent now, but I'd like to propose a new
Appender, too. I guess it is not so sophisticated and usefull as the
MultiplexAppender proposed recently, but therefore it is small and
simple. It's only one class, so I've simply attached it to this mail.
The Javadoc coments are rather low quality, but they should give a good
idea about how it works.

My motivation was, to store some LoggingEvents in my application, so
that they could be presented in its GUI later. In particular, was
writing some complex import filter, and was logging all import steps
with Log4j. But I also wanted to give the user some direct feedback
about the progress. Instead of accumulating messages for the GUI
seperately, I decided to use the existing Log4j infrastructure for this.
This would reduce the additional logging code in the import.

However the GUI is asynchronous to the import, so I needed to store the
LoggingEvents somewhere, and retrive them, whenever they should be
rendered. Of course, I could have used some Appender writing to a file,
and parse that file to display the events. But in fact the GUI didn't
need to make the events persistent, it just needed them in memory. So I
wrote that simple ListAppender, which buffers the LoggingEvents in a
List. The application using this Appender has full control of the List,
and can retrive or modify the stored LoggingEvent whenever it wants.

I could't find any similar Appender in the Log4j API docs. So either
you're in need of it, or it is completely unusefull for anyone else.
Please have a look at it, and decide yourself. If you think any of the
code could be usefull for Log4j, please feel free to use it.


PS: Thanks for all the other Appenders and Log4j in general. It's been
very usefull for me, so far.

View raw message