Configuring EL from within another application

Topics: General discussion, Logging Application Block
Feb 13, 2012 at 12:56 PM

In .Net 4.0 using EL 5.0 I have made an .exe (a Windows Service) which uses EL logging extensively.

I also have made a WinForms GUI  .exe for use as a development tool which enables. for example, the Windows Service to be installed, uninstalled, stopped, started etc.

 I want to be able to use the GUI to edit the Windows Service EL logging configuration, using a WinForms PropertyGrid component.

What is the best design for doing this with the least coupling between the UI and Windows Service?

I am happy to use the EL Conifguration Editor to actually create (and remove) logging Categories, Listeners etc. It is the values within these that need to changed in the development tool. For example - just change the FileName within a Logging Target Listener.

 

[ As some no-essential background.  I had originally thought that in the GUI I could read the EL configuration key/values with some foreach{} loop from a .config file into some collection, and wrap the collection keys as Properties decorated with suitable Attributes. After editing  another forreach} loop could  write the updated values form the collection back into the .config file. The only coupling would then be the path to the windows service .config.

However Fluent seems to have only an "all or nothing" apporach to saving using "UpdateConfigurationWithReplace" whihc effectively completely replaces the entire logging configuration. If all the user wants to do is turn logging off ("ToSourceLevels()....") this is a sledgehammer o crack a nut.]

 

 

 

 

 

 

Feb 14, 2012 at 1:12 AM

What if you were to read in the configuration sections and display appropriate values in your property grid?  When it was time to save the values you could overwrite the configuration file.

This would bypass the fluent interface and use the LoggingSettings configuration class directly.  For an example that would be similar to that approach you can see here.  That approach is not 100% the same since that example is for changing the configuration within the same appdomain.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com