In my Application I use Common.Logging
library in order to abstract logging functionality. In startup assembly it was configured (in app.config
file) to work against Log4Net
library. There are established some Appenders: ConsoleAppender
, RollingFileAppender
, TraceAppender
. Everything works fine in the single AppDomain
. However I have found that logging does not work in the newly created AppDomain
. i.e:
Logger.Info( "Logging works here" ); // Logging works here
var appDomain = AppDomain.CreateDomain(
"AppDomain." + componentHost.FullName,
AppDomain.CurrentDomain.Evidence,
AppDomain.CurrentDomain.SetupInformation );
var proxy = (IComponentHost) appDomain.CreateInstanceAndUnwrap(
componentHost.Assembly.FullName,
componentHost.FullName,
false,
BindingFlags.Default,
null,
new object[] { },
null,
null );
proxy.Init(); // Logging does not work in Init() method stack
I'm trying to find a solution, both using app.config
configuration as well as Common.Logging
API (i.e LogManager.Reset()
method), but it doesn't solve a problem.
How can I force Common.Logging / Log4Net
to work properly in newly created AppDomain
? Please for help.
I have a similar issue with log4net. I used XmlConfigurator.Configure() without parameters that uses Assembly.GetCallingAssembly() to get configuration file. I replaced it with: