For a project I have a WCF Service library (very simple at the moment) which is hosted in IIS 7.5 via a WCF Service Website project.
For that WCF Service library I need log4net to log some major events.
But after starting and accessing the website, no logfile is created.
Here are my configuration details:
WCF Service library:
App.config (is containing the following)
<appSettings>
<add key="log4net-config-file" value="log4net.config"/>
<!-- <add key="log4net.Internal.Debug" value="true"/> -->
</appSettings>
log4net.config
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
</configSections>
<log4net>
<root>
<level value="DEBUG"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\Temp\\Logfile.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<datePattern value="yyyyMMdd"/>
<maxSizeRollBackups value="5"/>
<maximumFileSize value="100KB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
</log4net>
</configuration>
In AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
On top of the Service class
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
In the Static Constructor (mainly due to fiddling around)
string configFile = ConfigurationManager.AppSettings["log4net-config-file"];
XmlConfigurator.Configure(new FileInfo(configFile));
logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
In the non-static constructor:
logger.Info("Hello world!");
Wcf Service Website project:
Web.Config is basically the same as App.Config of service library
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
What I have tried so far:
- Changing access to C:\Temp\ for IUSR (which is the one the service is running) to Write (and Modify)
- Restarting the machine
Reading lots of articles and SO Questions on the topic e.g. configuring log4net for iis hosted wcf service and this quick and dirty guide to log4net for webapplications
activated log4net internal logging (which is normally seen in DebugView)
There is no output in DebugView and nothing about log4net in the IIS configured logs.
How can I find out what is wrong?
What can I do to find out why it is not working?