0
votes

I'm using log4net logging in my software that consists of several applications. I want to have one common library 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?

1

1 Answers

1
votes

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".