title: log4Net filtering for multiple outputs confusion
body: <p>Trying to understand the log4net filtering. 
  After reading the docs some aspects are still elusive to me.</p>
  
  <p>For example I have this config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  
  &lt;log4net&gt;
    &lt;appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
      &lt;file value="..\Logs\CurrentLog" /&gt;
      &lt;appendToFile value="true" /&gt;
  
      &lt;rollingStyle value="Size" /&gt;
      &lt;maxSizeRollBackups value="10" /&gt;
      &lt;maximumFileSize value="10000" /&gt;
      &lt;staticLogFileName value="true" /&gt;
  
      &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
        &lt;acceptOnMatch value="true" /&gt;
        &lt;levelMin value="INFO" /&gt;
        &lt;levelMax value="FATAL" /&gt;
      &lt;/filter&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%-5level %date [%thread] %-22.22c{1} - %m%n" /&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;
  
    &lt;appender name="LogFileAppender" type="log4net.Appender.FileAppender"&gt;
      &lt;file value="log-file.txt" /&gt;
  
      &lt;appendToFile value="true" /&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;header value="Service Logging -- Start" /&gt;
        &lt;footer value="Service Logging -- End" /&gt;
        &lt;conversionPattern value="%date [%thread] %-5level %logger [%ndc] 
                   &amp;lt;%property{auth}&amp;gt; - %message%newline" /&gt;
      &lt;/layout&gt;
  
    &lt;/appender&gt;
  
  
    &lt;appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" &gt;
      &lt;applicationName value="WindowsService1.exe" /&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;!-- Set the default logging level and add the active appenders --&gt;
    &lt;root&gt;
      &lt;level value="DEBUG" /&gt;
      &lt;appender-ref ref="LogFileAppender" /&gt;
      &lt;appender-ref ref="RollingFileAppender" /&gt;
    &lt;/root&gt;
  
    &lt;!-- Specify the level for specific categories (“namespace.class”)--&gt;
    &lt;logger name="WindowsService1.MyMonitor"&gt;
      &lt;level value="WARN" /&gt;
      &lt;appender-ref ref="EventLogAppender" /&gt;
    &lt;/logger&gt;
  
  &lt;/log4net&gt;
  </code></pre>
  
  <p>My expectations were:</p>
  
  <ul>
  <li>The RollingFileAppender has a range of [INFO:FATAL]   The Root has a
  Level of DEBUG so it would let DEBUG and "greater" pass.   Which
  means all of RollingFileAppender's range would go through.</li>
  <li>The LogFileAppender has no range specified so it would use Root's of DEBUG or greater.</li>
  <li>And the EventLogAppender would only send event messages of WARN or greater to the    Windows Event System - <em>and</em> - they would only
  be messages from the class   "WindowsService1.MyMonitor".</li>
  </ul>
  
  <p>However it appears that <em>all</em> the messaging gets filtered to the WARN level!
  Including my rolling log files and the log file "log-file.txt"</p>
  
  <p>This seems like it should be simple - don't know why I'm so confused by it.
  Hope someone can enlighten me. 
  Please feel free to use crayons and pictures because I think I need them.
  Thanks.</p>
  
  <p><strong>UPDATE</strong><br>
  In my Program.cs I have:  </p>
  
  <pre><code>[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
  </code></pre>
  
  <p>And in each class where logging is done:</p>
  
  <pre><code>private static readonly ILog log =
              LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  </code></pre>
  
  <p><strong>UPDATE 2</strong>
  At a different computer now. Had to recreate everything and used log4net debugging to assist.<br>
  But still can't get the desired output.</p>
  
  <p>Basically want the WARN and above messages to go to one file and the Event logger. And those messages would be a subset of all the INFO and above messages.
  The INFO and above messages - superset - would go into the rolling appender and overwrite themselves eventually. But the warnings and errors would always be maintained.</p>
  
  <p>So here is a rework of all the files for a simple service. If I set WARN on the <code>appender-ref ref=EventLogAppender</code>  then all the INFOs are suppressed.</p>
  
  <p>Program.cs</p>
  
  <pre><code>[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
  
  // Ref: http://www.c-sharpcorner.com/UploadFile/naresh.avari/develop-and-install-a-windows-service-in-C-Sharp/
  //
  // use 'sc' to install/delete the service
  // run 'sc' as administrator
  //   sc create "MySillyService" binpath= "C:\whatever\something.exe"
  //   sc delete "MySillyService"
  
  namespace SimpleService1
  {
      static class Program
      {
          /// &lt;summary&gt;
          /// The main entry point for the application.
          /// &lt;/summary&gt;
          static void Main()
          {
  
              ServiceBase[] ServicesToRun;
              ServicesToRun = new ServiceBase[] 
              { 
                  new Service1() 
              };
              ServiceBase.Run(ServicesToRun);
          }
      }
  }
  </code></pre>
  
  <p>Service1.cs</p>
  
  <pre><code>namespace SimpleService1
  {
      public partial class Service1 : ServiceBase
      {
          private static readonly ILog log =
              LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  
          private Timer timer1;
          private int counter = 0;
          public Service1()
          {
              InitializeComponent();
          }
  
          protected override void OnStart(string[] args)
          {
              timer1 = new Timer();
              timer1.Interval = 4000;
              timer1.Elapsed += new ElapsedEventHandler(timer1_Tick);
              timer1.Enabled = true;
              log.Info("my service is started");
          }
  
          private void timer1_Tick(object sender, ElapsedEventArgs e)
          {
              counter++;
              if (counter%2 == 0)
              {
                  log.Info(String.Format("Counter({0:D}) is now even", counter));
              }
              else
              {
                  log.Error(String.Format("Counter({0:D}) is now even", counter));
              }
          }
  
          protected override void OnStop()
          {
              timer1.Enabled = false;
              log.Info("my service was stopped");
          }
      }
  }
  </code></pre>
  
  <p>App.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;startup&gt; 
          &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
      &lt;/startup&gt;
  
    &lt;appSettings&gt;
      &lt;add key="log4net.Internal.Debug" value="true"/&gt;
    &lt;/appSettings&gt;
    &lt;system.diagnostics&gt;
      &lt;trace autoflush="true"&gt;
        &lt;listeners&gt;
          &lt;add
            name="textWriterTraceListener"
            type="System.Diagnostics.TextWriterTraceListener"
            initializeData="C:\tmp\log4net.txt" /&gt;
        &lt;/listeners&gt;
      &lt;/trace&gt;
    &lt;/system.diagnostics&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Log4net.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  
  &lt;!--
    Ref: http://mitch-wheat.blogspot.com/2007/04/log4net-net-logging-tool.html
    I keep this config file in a separate directory and copy it with a 
    post-build event:
      copy /Y $(SolutionDir)Logger\Log4Net.config $(TargetDir)Log4Net.config
    --&gt;
  &lt;log4net&gt;
    &lt;appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
      &lt;file value="..\Logs\CurrentLog" /&gt;
      &lt;appendToFile value="true" /&gt;
  
      &lt;rollingStyle value="Size" /&gt;
      &lt;maxSizeRollBackups value="10" /&gt;
      &lt;maximumFileSize value="10000" /&gt;
      &lt;staticLogFileName value="true" /&gt;
  
      &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
        &lt;acceptOnMatch value="true" /&gt;
        &lt;levelMin value="INFO" /&gt;
        &lt;levelMax value="FATAL" /&gt;
      &lt;/filter&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%-5level %date [%thread] %-22.22c{1} - %m%n" /&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;
  
    &lt;appender name="LogFileAppender" type="log4net.Appender.FileAppender"&gt;
      &lt;file value="log-file.txt" /&gt;
  
      &lt;appendToFile value="true" /&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;header value="Service Logging -- Start - " /&gt;
        &lt;footer value="Service Logging -- End - " /&gt;
        &lt;conversionPattern value="%date [%thread] %-5level %logger [%ndc] 
                   &amp;lt;%property{auth}&amp;gt; - %message%newline" /&gt;
      &lt;/layout&gt;
  
    &lt;/appender&gt;
  
  
    &lt;appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" &gt;
      &lt;applicationName value="Service1" /&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;!-- Set the default logging level and add the active appenders --&gt;
    &lt;root&gt;
      &lt;level value="DEBUG" /&gt;
      &lt;appender-ref ref="LogFileAppender" /&gt;
      &lt;appender-ref ref="RollingFileAppender" /&gt;
    &lt;/root&gt;
  
    &lt;!-- Specify the level for specific categories (�namespace.class�)--&gt;
    &lt;logger name="SimpleService1.Service1"&gt;
      &lt;level value="WARN" /&gt;
      &lt;appender-ref ref="EventLogAppender" /&gt;
    &lt;/logger&gt;
  
  &lt;/log4net&gt;
  </code></pre>
  
  <p>Thanks for your help</p>