Hello.

 

I’m wondering about the following situation:

 

I have configured a RollingFileAppender to log in a file logs\host.log and another one (in a second config file) with exactly the same configuration except the file is logs\plugin.log. I’m running the host and configure log4net with the first config file, the host is logging as expected. The host runs in two threads and statements are logged with two different thread ids. Then I create a second AppDomain, load an assembly to it and create an object in that AppDomain. I unwrap the object handle and call it’s RunPlugin() method. I know that a thread can move between several AppDomains of one Win32 process but I expect the thread is running in the AppDomain where the object is created (in the other one I have only a proxy of the object).

Log.Info(“Plugin running”) does not work, there is no logs\plugin.log file neither a statement in ogs\host.log, but this I think is ok because the statement comes from another AppDomain and debugger says that log4net is not configured there. So I call XmlConfigurator.ConfigureAndWatch() with the plugin log config and there is my plugin.log with the statement. Fine.

 

But then I see something very interesting:

 

Host.log:

=======

2005-12-28 13:33:47,088 [3724] INFO […]

2005-12-28 13:33:47,179 [3721] INFO […]

2005-12-28 13:33:47,978 [3724] INFO […]

[…] // here we have two different threads in default AppDomain.

 

Plugin.log:

=========

2005-12-28 13:33:47,870 [3724] DEBUG […]

[…] // log file of my plugin AppDomain

 

 

And the new thread (I guessed) in the new AppDomain has the same thread id as the thread in the default AppDomain creating the new AppDomain and the plugin object in it. How does this come? How does log4net fetch the thread id?

 

Regards,

Marco

Reply via email to