While using log4net for logging and using a separate configuration file I encountered a strange error that log4net cant locate the configuration file, even though file and configurations are already there. This problem drive me nuts and finally i found few solutions to fix the problem.
My particular applications is designed as such
So as shown in diagram, several type of app type will hookup with Log4Net wrapper to get logging facility and all logging related logic’s are implemented on Log4Net wrapper. As the problem states every time a client app is trying to invoke log4net wrapper it gets xml configuration error “Check your .config file for the <log4net> and <configSections>….”
There is few problem and few solution, Solution can very on context.
On the client project , select Log4Net config file and set this file to Build Action of Content with Copy to Output Directory of Copy Always.
Another alternative is look for XmlConfigurator.Configure();. This line is responsible for initiating the log4net. This configuration should exist a single place where logging actually happen, not client app’s.
One of these 2 or both tricks should help to solve this problem.