Please don't hijack someone's thread by asking your own unrelated question.
The BufferingForwardingAppender does what you're asking: http://tinyurl.com/j7t9s http://logging.apache.org/log4net/release/config-examples.html#bufferingforwardingappender Have you tried it in your application? Is something not working? --- Meera Rajaram <[EMAIL PROTECTED]> wrote: > 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? > > Thanks, > Meera. > > -----Original Message----- > From: Daniel Bachler [mailto:[EMAIL PROTECTED] > Sent: Tuesday, April 11, 2006 9:37 AM > To: [email protected] > 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 > me. > > 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 > working > with an appender similar to FireEventAppender from the examples, or > are > there other suggested ways to do this(*)? The second thing I want to > achieve > is a little trickier. My old, custom logging framework had a function > called > 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 > was > 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 > to > do this. > > This brings me to the core question: FireEventAppender is implemented > as > a > 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 > that > this is not entirely in the spirit of log4net, which is why I > (finally) > ask: > Is there a possibility to get the reference to a certain Appender > that > was > created via config file magic? Something similar to > LogManager.GetLogger(), > along the lines of LogManager.GetAppenderByName(string name)? If it > isn't, > do you have any suggestions on how to implement the behaviour > described > above? > > TIA, > Daniel > > *) 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 > technique, > 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 > is > full, whichever comes first. Is this correct? Is there an > implementation > that does it this way maybe? > > -- > Daniel Bachler > http://www.danyx.com > 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 > >
