Hi I am trying to use Log4Net in WCF IIS hosted service, but it doesn\'t log any data. Has anyone achieved logging in WCF service using Log4Net?
I had the same issue as this and it was because I was using the relative path for the custom config file. I had the following line of code used:
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));
Through log4nets debug output, it was telling me it was looking for the log4net.config file in a root IIS directory, rather than anywhere in my application path.
So, change the line to something more direct to avoid this issue (if you also configure your custom config in this way):
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(@"G:\MyProject\log4net.config"));