title: Change log4net logging level programmatically
body: <p>This is similar to <a href="https://stackoverflow.com/questions/650694/changing-the-log-level-programmaticaly-in-log4net">650694</a> but no answer was accepted there, I can't get any of those suggestions to work at all, and I suspect I may be in a slightly different situation.</p>
  
  <p>I'm calling log4net.Config.XmlConfigurator.Configure().  But after that point in the program, I want to change the logging threshold to a value only known at runtime.</p>
  
  <p>From the other question, I tried:</p>
  
  <pre><code>((log4net.Repository.Hierarchy.Logger)mylogger.Logger).Level = log4net.Core.Level.Error;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>var appender = new log4net.Appender.ColoredConsoleAppender();
  appender.Layout = new log4net.Layout.PatternLayout(@"%date %-5level %message%newline");
  appender.Threshold = log4net.Core.Level.Error;
  appender.ActivateOptions();
  log4net.Config.BasicConfigurator.Configure(appender);
  </code></pre>
  
  <p>but neither one seems to have any effect: I'm still seeing DEBUG and INFO logging statements on the console.</p>
  
  <p>My hunch is that I'm adding a new appender, which has no effect on the appender declared in the XML config (which tells it to print DEBUG level messages), but I don't have any evidence for this yet.</p>
  
  <p>I've been digging through the log4net API for a while now, and I'm just not seeing it.  Is there something simple I'm missing?</p>