Oct 19, 2010 at 9:33 AM
Edited Oct 19, 2010 at 9:38 AM
I want to be able to enable/disable logging through our custom built WinForm. But the problem is that it doesn't persists. I'm
using the following code.
ExeConfigurationFileMap exeConfigFileMap = new ExeConfigurationFileMap();
exeConfigFileMap.ExeConfigFilename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(exeConfigFileMap, ConfigurationUserLevel.None);
LoggingSettings loggingSettings = config.GetSection(LoggingSettings.SectionName) as LoggingSettings;
LogEnabledFilterData logEnabledFilter = (LogEnabledFilterData)loggingSettings.LogFilters.Get("LogEnabled Filter");
logEnabledFilter.Enabled = false;
When I change the Enteprise Library Configuration tool, the settings are saved. Those settings are then reflected without any
problem on my Form. But, the second time I run my application, the settings are reverted back.
I'm using Enterprise Library 4.1
That's because it only updates the runtime configuration file of your application (applicationName.exe.config). It doesn't update your design time configuration which is the app.config file. So the next time you run it, whatever is the
content of the app.config is also what's in the runtime configuration file.
Global Technology and Solutions