title: Configuring Log4NetLoggerFactoryAdapter Programmatically
body: <p>I am using NUnit to test a project and I'd like to configure my tests to setup Common.Logging programmatically to use Log4Net. Here's what I've tried:</p>
  
  <pre><code>        NameValueCollection config = new NameValueCollection();
          //config.Add("configType", "EXTERNAL");
  
          var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DevelopMENTALMadness.Data.Sql.Tests.loggerconfig.xml");
          XmlConfigurator.Configure(stream);
  
          LogManager.Adapter = new Log4NetLoggerFactoryAdapter(config);
  </code></pre>
  
  <p>With the following file:</p>
  
  <pre><code>&lt;log4net&gt;
  &lt;appender name="A1" type="log4net.Appender.ConsoleAppender"&gt;
  
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="[%thread] %-4timestamp %-5level %logger %ndc - %message%newline" /&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;!-- Set root logger level to DEBUG and its only appender to A1 --&gt;
  &lt;root&gt;
      &lt;level value="DEBUG" /&gt;
      &lt;appender-ref ref="A1" /&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p></p>
  
  <p>And</p>
  
  <pre><code>        NameValueCollection config = new NameValueCollection();
          //config.Add("configType", "EXTERNAL");
  
          var x = new ConsoleAppender { Layout = new PatternLayout("[%thread] %-4timestamp %-5level %logger %ndc - %message%newline") };
          BasicConfigurator.Configure(x);
  
          LogManager.Adapter = new Log4NetLoggerFactoryAdapter(config);
  </code></pre>
  
  <p>But either it doesn't use the pattern I specify or if I uncomment the "configType" line it displays nothing at all. I'm just trying to select the layout I want so when I'm debugging my tests I can see the log output in the NUnit runner (Text Output).</p>