George V. Reilly

Using Log4Net from a COM+ Application

Log4Net

I spent far too much time on Friday trying to make log4net work in a COM+ ap­pli­ca­tion.

Someone else had done part of the work necessary, by creating an ap­pli­ca­tion.config for the COM+ ap­pli­ca­tion and setting a custom Ap­pli­ca­tion Root Directory. This was enough to ensure that most of the managed code in the ap­pli­ca­tion got their con­fig­u­ra­tion settings; log4net being the exception.

It took some additional work to realize that we needed to add two assembly attributes:

[assembly: log4net.Config.Repository("unique-name")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile="application.config")]

The repository name just needs to be a unique string. We used the name of the assembly.

blog comments powered by Disqus
Posting to dasBlog with Windows Live Writer » « Moving Offices