title: How to configure Microsoft Enterprise Library Logging Application Block to handle any logging category?
body: <p>I'm trying to use the <a href="http://netcommon.sourceforge.net/" rel="nofollow">Common Infrastructure Libraries for .NET</a> (Common.Logging) with Enterprise Library 4.1's Logging Application Block. According to the <a href="http://netcommon.sourceforge.net/docs/2.0.0/reference/html/ch01.html#d4e291" rel="nofollow">docs</a>, this is supported.</p>
  
  <p>The problem I'm encountering is that when I try to log something, like so (in this example I'm in an ASP.NET MVC application):</p>
  
  <pre><code>public ActionResult Index()
  {
      ViewBag.Message = "Welcome to ASP.NET MVC!";
  
      ILog log = LogManager.GetCurrentClassLogger();
      log.Info("Hello world!");
  
      return View();
  }
  </code></pre>
  
  <p>Instead of getting the log message, I'm getting an error in my event log:</p>
  
  <blockquote>
    <p>Message: There is no explicit mapping for the categories 'TestApp.Controllers.HomeController'.</p>
  </blockquote>
  
  <p>Well, there doesn't seem to be any option in Common.Logging to set the default category, and I can't figure out how to configure the LoggingConfiguration to accept any category, even if it isn't defined.</p>
  
  <p>Here's a snippet of my LoggingConfiguration:</p>
  
  <pre><code>&lt;loggingConfiguration name="Logging Application Block" tracingEnabled="true"
      defaultCategory="General" logWarningsWhenNoCategoriesMatch="true"&gt;
  ...
    &lt;categorySources&gt;
      &lt;add switchValue="All" name="General"&gt;
        &lt;listeners&gt;
          &lt;add name="Formatted EventLog TraceListener" /&gt;
          &lt;add name="Email TraceListener" /&gt;
        &lt;/listeners&gt;
      &lt;/add&gt;
    &lt;/categorySources&gt;
    &lt;specialSources&gt;
      &lt;allEvents switchValue="All" name="All Events" /&gt;
      &lt;notProcessed switchValue="All" name="Unprocessed Category" /&gt;
      &lt;errors switchValue="All" name="Logging Errors &amp;amp; Warnings"&gt;
        &lt;listeners&gt;
          &lt;add name="Formatted EventLog TraceListener" /&gt;
        &lt;/listeners&gt;
      &lt;/errors&gt;
    &lt;/specialSources&gt;
  &lt;/loggingConfiguration&gt;
  </code></pre>
  
  <p>I've tried setting <code>logWarningsWhenNoCategoriesMatch</code> to false, but that just silences the warning -- it doesn't make the logging work.</p>
  
  <p>I've also tried getting rid of the <code>&lt;notProcessed switchValue="All" .../&gt;</code> special source, but that doesn't seem to have any effect either.</p>
  
  <p>Anyone know if there's a way to get this to work? Thanks!</p>