title: log4net not working in a windows service
body: <p>I have a console app which I am converting into a windows service. As a console app my log4net logging is working fine. But converting it into a windows service, my log4net logging has stopped working.</p>
  
  <p>I have added this to my assemblyInfo.cs in the service project:</p>
  
  <pre><code>[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] 
  </code></pre>
  
  <p>This is my service class with onstart and onstop:</p>
  
  <pre><code>private static log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
          private Builder _builder;
  
          public YCSWebServerService()
          {
              InitializeComponent();
              _builder = new Builder();
          }
  
          protected override void OnStart(string[] args)
          {
              _log.Info("YCSWebServerService started");
              _builder.Start();
          }
  
          protected override void OnStop()
          {
              _log.Info("YCSWebServerService stopped");
              _builder.Stop();
          }
  </code></pre>
  
  <p>I have a "specific" log4net config file added to my service project:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
  
    &lt;configSections&gt;
      &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /&gt;
    &lt;/configSections&gt;
  
    &lt;log4net&gt;
      &lt;root&gt;
        &lt;level value="ALL" /&gt;
        &lt;appender-ref ref="EventLogAppender" /&gt;
      &lt;/root&gt;
      &lt;appender name="EventLogAppender" type="log4net.Appender.EventLogAppender"&gt;
        &lt;threshold value="DEBUG" /&gt;
        &lt;applicationName value="Lantic YCS WebServer" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="(%-5level %date{hh}:%date{mm}:%date{ss} [%thread] %logger [%property{NDC}] ) %message %n" /&gt;
        &lt;/layout&gt;
      &lt;/appender&gt;
    &lt;/log4net&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Any ideas or tips?</p>