I have used log4net in winforms before. First time using with a wpf console app. The console shows up and the console appender works exactly as in the winforms app. However in winforms I never had to give the full path to the log4net xml file. It is located in the same place where all the cs files are. (the default place where VS 2010 puts all its source files. So
XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log4config.xml"));
works in a winforms app’s Program.cs->main() but for the wpf version where I have my own Startup class with my own Main() (instead of the autogenerated and hidden main()) I have to change the line to look like this
XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(@"c:\fullpath\log4config.xml"));
This took me quite a while to nail down so I thought it may be worthwhile to figure why this is so. Anyone know ? I am using log4net ver 1.2.10.0. The log4net dll and xml both have copy to local = true in winforms and wpf. thank you
That syntax applies to the log4net.dll, but for the log4config.xml file, it should have a property called ‘Copy to Output Directory’ which has options ‘Do not Copy’, ‘Copy if newer’ and ‘Copy Always’.
When you run it, does the log4config.xml actually exist in the ..\bin\debug or ..\bin\release folder and if so, is it the correct version of the file.?
As Shrieks has said, this is probably not a log4net issue, since log4net should be simply using the FullName property of the FileInfo object that has been created and passed to it.