Feb 13, 2007 at 4:42 PM
Edited Feb 13, 2007 at 5:00 PM
Hi, I am implementing a WebService that requires high availability. I want to include some methods in the service which will allow me (using appropriate authentication) to change the logging configuration and also retrieve the log. I can get the log file
once I can read the configuration to see where the file is written. How can i read the configuration? More importantly, how can I programmatically change the log settings to include more verbose logging? I know how to do all this with the config file, but
I'd like to be able to do it by calling a method of my web service so I can do it remotely. Can anyone help?
Note that I have read David Hayden's articles about creating all the log objects programmatically and would PREFER not to do it that way if possible.
You can read the Logging Application Block Configuration Settings as follows:
IConfigurationSource mySource = ...;
LoggingSettings settings = LoggingSettings.GetLoggingSettings(mySource);
For normal web.config / app.config deployment you would use:
LoggingSettings settings = LoggingSettings.GetLoggingSettings(new SystemConfigurationSource());
There are a number of collections and properties on the class that you can read depending on what you need.
As far as writing changes back, I have not done it during run-time so I am unsure of the best way at this moment.
It is done via serialization at design time, and you can check the source code for more information on that.
Microsoft MVP C#