开发者

Using log4net in a complex software

I'm using log4net logging in my software that consists of several applications. I want to have one common lib开发者_如何学编程rary for this. I created a library and put it in the conficuration file. In AssemblyInfo.cs placed attribute: log4net.Config.XmlConfigurator(ConfigFile = @"c:\logging.xml", Watch = true)

It work for windows service, but in dosn't work for asp.net application. It work in asp.net if delete attribute from common library and put in into global.asax. However, this leads to that section of the log4net configuration must be made in the windows service.

There is also a business process which causes our library through the remouting. I want the logging was carried out there too.

Is there way around this?


In my opinion the library should not define where the configuration file is found. Maybe a better idea would be to have a helper method that allows you to configure log4net quickly; that method would take an optional parameter for the config file path and would try to load the configuration file from the specified path first and if that does not work fallback to some maybe the current folder, the application folder or even the web / app.config.

If you insist that it must be an absolute path then you need to give the IIS Application Pool user read access to this file. This way the configuration by attribute should work for services and ASP.Net applications. I do not understand what you mean by "remounting".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜