title: log4net's LogManager.GetLogger() throws NullReferenceException when used in custom TraceListener
body: <p>I am attempting to transition a large application from using the <code>Trace</code> class to output notifications through <code>log4net</code>.  As such, I wrote a custom <code>TraceListener</code> to redirect output into the log4net's messaging (inspired by <a href="http://blog.catenalogic.com/post/2010/06/18/Log4net-TraceListener.aspx" rel="nofollow">this post</a>).</p>
  
  <pre><code>public class Log4netTraceListener : TraceListener
  {
      private static readonly ILog logger = LogManager.GetLogger("Log4netTraceListener"); // Line 19
  
      public Log4netTraceListener() { /* nothing special */ }
  
      public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
      {
          // some switching based on the TraceLevel, but eventually something like:
          logger.Error(message);
      }
  }
  </code></pre>
  
  <p>The console application solution was three projects:</p>
  
  <ol>
  <li>RunShipOrder - the console project that is the entry point for the application</li>
  <li>ShipOrderAPI - a class library project that contains all of the code relevant to this process</li>
  <li>CodeLibrary - a class library project that contains code common across many projects.
  <ul>
  <li>Log4netTraceListener is in this project</li>
  </ul></li>
  </ol>
  
  <p>Inside of the <code>RunShipOrder</code> project, I can call <code>LogManager.GetLogger("Log4netTraceListener")</code>, and it works as expected.  However, if I try to call a method on <code>Trace</code> it throws an exception.  I have traced it back to the initial call to <code>LogManager.GetLogger("Log4netTraceListener")</code> inside of the <code>Log4netTraceListener</code> class.</p>
  
  <p>The Exception thrown is a <code>ConfigurationErrorsException</code>, with an inner exception of <code>TypeInitializationException</code>, with an inner exception of <code>NullReferenceException</code>.
      The stack trace on the innermost exception is:</p>
  
  <pre><code>   at log4net.Core.LoggerManager.GetLogger(Assembly repositoryAssembly, String name)
     at log4net.LogManager.GetLogger(Assembly repositoryAssembly, String name)
     at log4net.LogManager.GetLogger(String name)
     at CodeLibrary.Diagnostics.Log4netTraceListener..cctor() in Log4netTraceListener.cs:line 19
  </code></pre>
  
  <p>Any ideas on what might be throwing this exception from within the log4net codebase?</p>