logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Meera Rajaram" <mraja...@vitalimages.com>
Subject RE: Accessing Appender that was created via config file?
Date Tue, 11 Apr 2006 14:57:23 GMT
I am using RollingFileAppender to log messages. Is there a way in which
I can cache the messages before writing them out to the file? Ideally
the cache size would be in the configuration file. When the total size
of the messages (I need the writing to be done based on size of all
messages and not based on number of cached messages) reaches the cache
size, I need the messages to be written to the log file. I am new to
log4Net so I am not sure if I can use BufferingForwardingAppender in
some way to achieve this? 


-----Original Message-----
From: Daniel Bachler [mailto:DanyX@gmx.net] 
Sent: Tuesday, April 11, 2006 9:37 AM
To: log4net-user@logging.apache.org
Subject: Accessing Appender that was created via config file?

Hi all,

I am currently in the process of switching my app and a few libraries I
wrote to log4net. So far everything works fine, but now I am at a point
where I need the help of people who have more insight into log4net than

I want to accomplish two things: First I want an appender to output to a
multiline textbox of my app. I think that this might be easiest by
with an appender similar to FireEventAppender from the examples, or are
there other suggested ways to do this(*)? The second thing I want to
is a little trickier. My old, custom logging framework had a function
SetJob(string currentJob) that would output the string given to what is
called the appenders in log4net, but there would be special handling to
update a small label in the UI to inform the user of what the app is
currently doing. I thought that the best way to get a similar behaviour
to log objects of type JobMessage or something to replace
SetJob(currentJob), and writing a filter to filter based on type and an
appender that would write this info to the UI. Again, it seems that
something along the lines of FireEventAppender would be the easiest way
do this.

This brings me to the core question: FireEventAppender is implemented as
weird kind of singleton. Implementing something like FireEventAppender
as a
singleton would of course be possible, but then I could only have 1 and
would have to do the filtering (directing most output to the multiline
textbox and some to the Current Job UI Label) myself. It seems to me
this is not entirely in the spirit of log4net, which is why I (finally)
Is there a possibility to get the reference to a certain Appender that
created via config file magic? Something similar to
along the lines of LogManager.GetAppenderByName(string name)? If it
do you have any suggestions on how to implement the behaviour described


*) As a sidenote: Since some of my function can output a lot of messages
within a short amount of time that I want to appear in the multiline
textbox, I implemented a mechanism to store the messages in memory and
append them to the multiline textbox via a timer event. The log4net
BufferingForwardingAppender seems to be an alternative to this
but as far as I understand it there is no way to get the current
implementation to output either every n seconds or whenever the buffer
full, whichever comes first. Is this correct? Is there an implementation
that does it this way maybe?

Daniel Bachler
Contact details: http://www.danyx.com/contact
The attatched file starting with ATT is a signature for this message. To
understand how you can verify my identity based on this signature,
please go
to http://www.danyx.com/WhyGPG

View raw message