I have a windows service where the app.config file and the log4net.config files are seperate. The logging is not working.
In my app.config file, I have the following in
For Windows service the current directory is Windows\system32 -- and XmlConfigurator.Configure() uses FileInfo which treats relative paths relative to the current directory. So log4net is looking for its config file in Windows\system32.
XmlConfiguratorAttribute on the other hand uses application's BaseDirectory, this is why it always works.
Alternatively, you can do following before calling XmlConfigurator.Configure() :
System.IO.Directory.SetCurrentDirectory (AppDomain.CurrentDomain.BaseDirectory);