Okay, I think I've got it.
I strongly suspect that this:
<appender name="FormMain" type="Client.FormMain,Client" />
... is getting log4net to create a new instance of FormMain
. So you've got one instance being shown, but there's another form which isn't being shown, but is receiving append calls.
You should be able to see that in the debugger - if you put breakpoints in both DoAppend
and bTestLog_Click
, you'll see the instance that the methods are being invoked on being different.
I don't know the best way of hooking log4net into an existing object, but you may find that you can just programmatically add an appender in log4net; you should look at the API for more details.
As an aside, I'd probably separate the concerns of "being an appender" and "being a form" - I'd create an implementation of IAppender
which appends to a text box which is provided in its constructor, and then pass the relevant text box from the form when you construct the appender. That's a slightly different matter though :)