title: log4Net EventlogAppender does not work for Asp.Net 2.0 WebSite?
body: <p>I have configured log4Net EventLogAppender for Asp.Net 2.0. However it does not log anything. I have following in my Web.Config.</p>
  
  <pre><code>&lt;log4net&gt;
      &lt;appender name="EventLogAppender" type="log4net.Appender.EventLogAppender"&gt;
        &lt;param name="LogName" value="Test Log" /&gt;
        &lt;param name="ApplicationName" value="Test-Web" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /&gt;
        &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;root&gt;
        &lt;priority value="ERROR"/&gt;
        &lt;appender-ref ref="EventLogAppender"/&gt;
      &lt;/root&gt;
      &lt;logger name="NHibernate"&gt;
        &lt;level value="ERROR" /&gt;
        &lt;appender-ref ref="EventLogAppender" /&gt;
      &lt;/logger&gt;
    &lt;/log4net&gt;
  </code></pre>
  
  <p>I already have Test-Log Event Log created and AspNet user has permission on the Event Log registry entry. I also have log4Net configured in Global.asax Application_Start.</p>
  
  <pre><code>log4net.Config.XmlConfigurator.Configure();
  </code></pre>
  
  <p><strong>Update</strong> : I switched on the log4net internal debugging and found the following error in the trace.</p>
  
  <pre><code>log4net:ERROR XmlHierarchyConfigurator: Could not create Appender [EventLogAppender] of type [log4net.Appender.EventLogAppender]. Reported error follows.
  System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.
     at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly)
     at System.Diagnostics.EventLog.SourceExists(String source, String machineName)
     at System.Diagnostics.EventLog.SourceExists(String source)
     at log4net.Appender.EventLogAppender.ActivateOptions()
     at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
  </code></pre>
  
  <p><strong>Update 2</strong> : It finally works if I create the Event Source (Test-Web) using a console based application in c# and then using the Web Application.</p>