Enterprise Library 6.0 - Rolling Log File configuration in 2 configuration files

Topics: Logging Application Block
Mar 25, 2014 at 12:37 PM
I have a suite of applications which all use the enteriprise logging. I would like for each of the applications to have local configuration file which configures a listener so that the name of the rolling log file can be defined.

I would like to have a common logging configuration file which then contains the formatters, logFilters, categorySources, and specialSources.

When I try and split these configurations into 2 configuration files, the code can't seem to find the second configuration.

Does anyone know if this is possible? Any examples of anyone doing this?

This is what I have in my app config which does not work:

<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<loggingConfiguration configSource="LoggingConfiguration.config"/>
<loggingConfiguration configSource="LoggingConfiguration_2.config"/>

which throws:
"Sections must only appear once per config file. See the help topic <location> for exceptions.
Mar 26, 2014 at 1:44 PM
You cannot use more than one configSource for the same section (as you found out from the error message).

If you have a parent configuration source and you want a child configuration source to overwrite settings in that configuration source then you can do that. See Scenario 6: Applying a Common Configuration Structure for Applications from Appendix D of the Developer's Guide as well as Merge Rules for Inherited Configuration.

The parent configuration file would need to have the entire Enterprise Library configuration and not just logging.

There is also a thread discussing merging more than one configuration source (if you need that) which might be useful/interesting: http://entlib.codeplex.com/discussions/253733 .

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to