I'm using log4net version 1.2.10.0 on MS .NET 2.0. My assembly type is an MbUnit (unit test) DLL. I'm launching it using TestDriven.NET. The test code is exercising our framework library.

The question I have is about how the log4net configuration gets loaded in this instance.

If I use MbUnit in its default, which launches tests using a multithreaded apartment (MTA) then none of the logging in my framework code works UNLESS I first do LogManager.GetLogger and make a call to a logging method (like ILog.Warn("foo")) before any framework code executes.

I can change the way MbUnit load the TestFixture by forcing it to use singlethreaded apartment (STA) but then I still must make the LogManager.GetLogger call or the logging in the framework still fails to write.

My framework code uses the [assembly: XmlConfigurator(ConfigFile="logging.config" Watch=true)] configuration mechanism. I'm using the RemotingAppender and have confirmed that it works as expected to our LoggingServer (which hosts the proper log4net plugin). I also tested using a LogFileAppender to eliminate any problems with the RemotingAppender setup. My unit test code loads the config in the same way. I initially didn't have any log4net code or references in my test assembly, thinking I shouldn't need them as long as the logging.config file was good-to-go for my framework assembly to load.

Can someone explain this behavior, and if maybe I am missing something in this situation? I'd like not to have to educate our developers to perform this 'extra' setup and logging statement in every TestFixture they write.

Thanks in advance,
Danny

Reply via email to