Hi,

 

I’m trying to enable a MemoryAppender and access the logged information from within code to be displayed in a form.   Ideally I’d like the MemoryAppender to be configured in the config file.  I already have a working config file which logs to a file and the debugger, and I added the following currently posted example:

 

<appender name="MemoryAppender" type="log4net.Appender.MemoryAppender" >

            <onlyFixPartialEventData value="true" />

</appender>

 

 

After looking at the MemoryAppender class documentation which states the data is found inside MemoryAppender.Events, I tried code such as the following (assumes LogRtbx is defined as a rich textbox):

 

MemoryAppender memoryAppender = new MemoryAppender();

Log.Error(“Test Error Message”);

This.LogRtbx.AppendText(memoryAppender.Events[0].RenderedMessage.ToString());

 

When I try this, I get an error that when handled shows that there is no data at all in Events.  It doesn’t work to remove the declaration. If the MemoryAppender is being created from the config file, how can I access the MemoryAppender object or am I completely off course?

 

Recap:

1)       Why does the current posted example suggest that you probably would not want to configure the MemoryAppender in the config file?

2)       How can I read the logged information from memory to be displayed in a Windows form?  Are there any examples besides the config file example?

 

Thanks,

Kevin

 

 

Reply via email to