title: log4net MemoryAppender not working
body: <p>I'm using log4net to log in my app. My FileAppender is working fine, but I'm having problems with MemoryAppender.</p>
  
  <p>Here is my config file.</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;appender name="LogFileAppender" type="log4net.Appender.FileAppender"&gt;
    &lt;param name="File" value="Envision.log" /&gt;
    &lt;param name="AppendToFile" value="true" /&gt;
    &lt;layout type="log4net.Layout.PatternLayout"&gt;
      &lt;param name="Header" value="" /&gt;
      &lt;param name="Footer" value="" /&gt;
      &lt;param name="ConversionPattern" value="%d [%t] %-5p %m%n" /&gt;
    &lt;/layout&gt;
  &lt;/appender&gt;
  &lt;appender name="MemoryAppender" type="log4net.Appender.MemoryAppender"&gt;
  
  &lt;/appender&gt;
  &lt;root&gt;
    &lt;level value="ALL" /&gt;
    &lt;appender-ref ref="LogFileAppender" /&gt;
    &lt;appender-ref ref="MemoryAppender" /&gt;
  &lt;/root&gt;
  &lt;/log4net&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I use this code to setup the config file.</p>
  
  <pre class="lang-cs prettyprint-override"><code>FileInfo file = new FileInfo(configPath);
  log4net.Config.XmlConfigurator.Configure(file);
  file = null;
  </code></pre>
  
  <p>Like I said, the FileAppender works great. But I can't seem to get any events.
  I've tried using something like this to get the MemoryAppender.</p>
  
  <pre class="lang-cs prettyprint-override"><code>Hierarchy hierarchy = LogManager.GetRepository() as Hierarchy;
  MemoryAppender mappender = hierarchy.Root.GetAppender("MemoryAppender") as MemoryAppender;
  </code></pre>
  
  <p>I've tried using:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var events = mappender.GetEvents()
  </code></pre>
  
  <p>after logging something, and events is always empty. I've tried setting up the FileAppender and MemoryAppender in code instead of using the config file, and I get the same, the FileAppender works fine, but can't seem to get any events from MemoryAppender. Curious if I'm understanding MemoryAppender right? I also tried setting up a thread that loops checking for the GetEvents to not be empty, and while logging away it always comes back empty. I've tried setting the Threshold to Core.Level.All on the MemoryAppender but that did not change anything.</p>
  
  <p>Thanks for any direction. I've looked around, and from the sites I've seen, I can't tell what I'm doing different.</p>
  
  <p>Even something as simple as this does not work. events length is always zero;</p>
  
  <pre class="lang-cs prettyprint-override"><code>public partial class MainWindow : Window {
      public MainWindow() {
          InitializeComponent();
  
          MemoryAppender appender = new MemoryAppender();
          ILog logger = LogManager.GetLogger("foo");
          BasicConfigurator.Configure(appender);
  
          logger.Error("Should work");
          var events = appender.GetEvents();
      }
  }
  </code></pre>