Logging Configuration

Topics: Building and extending application blocks, Enterprise Library Core, Logging Application Block
Nov 2, 2007 at 6:00 PM
I would like to create a windows form application that would allow me to modify logging settings similar to the Enterprise Library Configuration tool.

I want use the same design and architecture as the Enterprise Library Configuration tool. Where would I start looking for examples? I have looked at the source code for the configuration tool, but it is Greek to me at this point.

Can anyone point me in the right direction?


Nov 5, 2007 at 3:33 PM
Hi Travis,

Do you want to build a tool to author a configuration file or to modify its own configuration file? What kind of changes do you want to make?

I suggest you take a look at the "CanDeserializeSerializedConfiguration" test methods in the logging block's test project. The show how to save and retrieve configuration using just the configuration objects and the configuration sources.

Nov 5, 2007 at 10:01 PM
Thanks Fernando for your post, I appreciate it.

I would like to build a tool to author a configuration file and be able to edit. I would love to use the Enterprise Library Configuration tool, but my configuration file is stored in a separate file, like "loggingsetting.config".
The Enterprise Library Configuration tool doesn't allow you to save changes to a "configSource". I also need to add some additional functionality.

I attempted to modify the Enterprise Library Configuration tool, but found myself a little overwhelmed by the design. I would like to use the Configuration.Design and Configuration.Design.UI, but have not been able to wrap my head around the architecture. I took a look at the unit test projects and I understand how to get the configuration sections. The next step would be to display this data and be able to modify values. I do not want to reinvent the wheel here, but I do not see another other solution because of the Enterprise Library Configuration tool doesn't allow you to save to a configuration source.


Nov 6, 2007 at 11:42 AM
Hi Travis,

The configuration tool relies on the functionality provided by the System.Configuration assembly to save, so you will need to make sure you make the required information available.
This means you'll need to extract this information when reading, and setting it when regenerating the nodes. The ConfigurationSectionNode class is the most likely recipient for this information; look at how the "RequirePermission" flag is handled for an example.

The snippet below shows how to save configuration so the section is saved to a detached file; you will need to make sure the configSource value is set before you add the section to the config.

class Program
static void Main(string[] args)
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = "test.exe.config";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

MySection section = new MySection();
section.Prop1 = "test";
section.SectionInformation.ConfigSource = "section.config";

config.Sections.Add("mysection", section);


public class MySection : ConfigurationSection
private const string Prop1PropertyName = "prop1";
public string Prop1
get { return (string)thisProp1PropertyName; }
set { thisProp1PropertyName = value; }