title: How do I Filter on a custom Level in log4net?
body: <p>I copied the log4net samples to implement a custom log level, AUDIT. I defined AUDIT to have a value of 35000, between DEBUG 30000 and INFO 40000.</p>
  
  <p>The following is my configuration section. I have one appender that logs all levels and one that is supposed to log only AUDIT levels (this is just for testing)</p>
  
  <pre><code>&lt;log4net&gt;
    &lt;appender name="FileAppender" type="log4net.Appender.FileAppender" &gt;
      &lt;file value="testrun.log" /&gt;
      &lt;layout type="log4net.Layout.PatternLayout" &gt;
        &lt;conversionPattern value="%date{HH:mm:ss:fff} [%thread] %-5level %logger{1} - %message%newline" /&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;
    &lt;appender name="FileAppender.Audit" type="log4net.Appender.FileAppender" &gt;
      &lt;filter type="log4net.Filter.LevelMatchFilter"&gt;
        &lt;levelToMatch value="AUDIT" /&gt;
      &lt;/filter&gt;
      &lt;file value="testrun.audit.log" /&gt;
      &lt;layout type="log4net.Layout.PatternLayout" &gt;
        &lt;conversionPattern value="%date{HH:mm:ss:fff} [%thread] %-5level %logger{1} - %message%newline" /&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;  
    &lt;root&gt;
      &lt;level value="ALL" /&gt;
      &lt;appender-ref ref="FileAppender" /&gt;
      &lt;appender-ref ref="FileAppender.Audit" /&gt;
    &lt;/root&gt;
  &lt;/log4net&gt;
  </code></pre>
  
  <p>The test method is </p>
  
  <pre><code>private static readonly IAuditLog log = AuditLogManager.GetLogger(typeof(Program));
  public static void Main()
  {
      log.Debug("Debug");
      log.Audit("Audit");
      log.Info("Info");
  }
  </code></pre>
  
  <p>However, the output of the appenders is the same...</p>
  
  <pre><code>13:09:11:540 [9] DEBUG Program - Debug
  13:09:11:560 [9] AUDIT Program - Audit
  13:09:11:560 [9] INFO  Program - Info
  </code></pre>
  
  <p>The log4net debug output when parsing the LevelMatchFilter is</p>
  
  <pre><code>log4net: Loading Appender [FileAppender.Audit] type: [log4net.Appender.FileAppender]
  log4net:ERROR XmlHierarchyConfigurator: Unknown Level Specified [AUDIT]
  log4net:WARN Unable to set property [levelToMatch] on object [log4net.Filter.LevelMatchFilter] using value [AUDIT] (with acceptable conversion types)
  log4net: Setting Collection Property [AddFilter] to object [log4net.Filter.LevelMatchFilter]
  </code></pre>