You can make sure that your log4net.xml file is set to Always Copy (right-click on log4net.xml → Properties → Copy to Output Directory = Always Copy). To make sure your configuration file is copied, you should check the bin \ debug or bin \ release directory and make sure that the log4net.xml file exists in the same directory that your application runs.
If this does not work, you can try turning on internal debugging in log4net. To enable internal debugging, add the following key to the app.config file. This will send log4net internal debugging messages to the Visual Studio output window (View → Output).
<configuration> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> </configuration>
For more information on log4net internal debugging, you can mark the Phil Haack blog post here .
If all else fails, you can enable internal debugging and explicitly load the configuration by calling the log4net XmlConfigurator.ConfigureAndWatch method.
var fi = new FileInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\log4net.xml"); XmlConfigurator.ConfigureAndWatch(fi);
Dustin venegas
source share