I am trying to use Common Infrastructure Libraries for.NET (Common.Logging) with corporate library 4.1. Launch application block. According to docs , this is supported.
The problem I am facing is that when I try to write something, for example (in this example I am using an ASP.NET MVC application):
public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; ILog log = LogManager.GetCurrentClassLogger(); log.Info("Hello world!"); return View(); }
Instead of receiving a log message, I get an error message in the event log:
Message: There is no explicit mapping for the categories "TestApp.Controllers.HomeController".
Well, it seems that in Common.Logging there is no option to set the default category, and I cannot figure out how to configure LoggingConfiguration to accept any category, even if it is not defined.
Here is a snippet of my LoggingConfiguration setup:
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true"> ... <categorySources> <add switchValue="All" name="General"> <listeners> <add name="Formatted EventLog TraceListener" /> <add name="Email TraceListener" /> </listeners> </add> </categorySources> <specialSources> <allEvents switchValue="All" name="All Events" /> <notProcessed switchValue="All" name="Unprocessed Category" /> <errors switchValue="All" name="Logging Errors & Warnings"> <listeners> <add name="Formatted EventLog TraceListener" /> </listeners> </errors> </specialSources> </loggingConfiguration>
I tried setting logWarningsWhenNoCategoriesMatch to false, but it just silences the warning - it does not do the logging work.
I also tried to get rid of the special source <notProcessed switchValue="All" .../> , but this also has no effect.
Does anyone know if there is a way to make this work? Thanks!
source share