Ent Lib 5.0 Logging to Multiple Categories

Topics: Logging Application Block
Apr 1, 2013 at 2:07 PM
We recently upgraded to Ent Lib 5.0 on one of our projects and are now seeing logging errors. I have a logging method that can assign multiple categories to a given log entry. Here is the code for the assignment:
Categories = new string[] { BusinessLogicCategory, category.ToString() }
Suppose that BusineLogicCategory = "BusinessLogicLayer" and category = "AuthAction". For the config file, I have BusinessLogicLayer defined in the categorySources section but NOT AuthAction:
            <add name="BusinessLogicLayer" switchValue="All">
                    <add name="Msmq TraceListener" />
With Ent Lib 4.1, this would result in just one log. Now, we get the one log as well as an Error log with the error "There is no explicit mapping for the categories 'AuthAction'". I am assuming that this is because I have two categories defined on the log but only one of those categories defined in the config file. However, this did not appear to be an issue in 4.1. Can someone confirm if this is expected behavior and if there is any way to avoid the Error log?
Apr 1, 2013 at 3:49 PM
Edited May 1, 2013 at 9:33 PM
There is a setting in the configuration, logWarningsWhenNoCategoriesMatch that causes a log entry to be written if a category is specified that does not match in the configuration. It sounds like you don't want this to happen so set it to false:
    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General"
Randy Levy
Enterprise Library support engineer
Support How-to