title: log4net for WCF Service library hosted in IIS
body: <p>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.</p>
  
  <p>For that WCF Service library I need log4net to log some major events.</p>
  
  <p>But after starting and accessing the website, no logfile is created.</p>
  
  <p><strong>Here are my configuration details:</strong></p>
  
  <p><strong>WCF Service library:</strong></p>
  
  <pre><code>App.config (is containing the following)
  
  &lt;appSettings&gt;
      &lt;add key="log4net-config-file" value="log4net.config"/&gt;
      &lt;!-- &lt;add key="log4net.Internal.Debug" value="true"/&gt; --&gt;
  &lt;/appSettings&gt;
  
  log4net.config
  
  &lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="log4net" type="System.Configuration.IgnoreSectionHandler"/&gt;
    &lt;/configSections&gt;
    &lt;log4net&gt;
      &lt;root&gt;
        &lt;level value="DEBUG"/&gt;
        &lt;appender-ref ref="RollingLogFileAppender"/&gt;
      &lt;/root&gt;
      &lt;appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
        &lt;file value="C:\\Temp\\Logfile.txt"/&gt;
        &lt;appendToFile value="true"/&gt;
        &lt;rollingStyle value="Size"/&gt;
        &lt;datePattern value="yyyyMMdd"/&gt;
        &lt;maxSizeRollBackups value="5"/&gt;
        &lt;maximumFileSize value="100KB"/&gt;
        &lt;staticLogFileName value="true"/&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%d [%t] %-5p %c - %m%n"/&gt;
        &lt;/layout&gt;
      &lt;/appender&gt;
    &lt;/log4net&gt;
  &lt;/configuration&gt;
  
  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!");
  </code></pre>
  
  <p><strong>Wcf Service Website project:</strong></p>
  
  <pre><code> Web.Config is basically the same as App.Config of service library
  
   &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/&gt;
  </code></pre>
  
  <p><strong>What I have tried so far:</strong></p>
  
  <ul>
  <li>Changing access to C:\Temp\ for IUSR (which is the one the service is running) 
  to Write (and Modify)</li>
  <li>Restarting the machine</li>
  <li><p>Reading lots of articles and SO Questions on the topic
  e.g. <a href="http://www.dylanmorley.com/blog/post/Using-log4net-in-a-WCF-service-hosted-by-IIS.aspx" rel="nofollow">configuring log4net for iis hosted wcf service</a> and this <a href="http://haacked.com/archive/2005/03/07/ConfiguringLog4NetForWebApplications.aspx/" rel="nofollow">quick and dirty guide to log4net for webapplications</a></p></li>
  <li><p>activated log4net internal logging (which is normally seen in DebugView)</p></li>
  </ul>
  
  <p>There is no output in DebugView and nothing about log4net in the IIS configured logs.</p>
  
  <p>How can I find out what is wrong? </p>
  
  <p>What can I do to find out why it is not working?</p>