| .NET DotNet Forum Index » .NET Framework Forum » App.config updates... |
|
Page 1 of 1 |
|
| Author |
Message |
| Peter Larsen [CPH]... |
Posted: Fri Oct 09, 2009 6:39 am |
|
|
|
Guest
|
Hi,
How to i update a TraceSwitch from app.config in runtime - without
restarting the application.
I use dotNet 3.5.
I know how to refresh the section in memory, but i dont know how to read the
properties from the updated section.
This is what i have:
System.Configuration.ConfigurationManager.RefreshSection("system.diagnostics");
object section =
System.Configuration.ConfigurationManager.GetSection("system.diagnostics");
TraceSwitch fileTraceLevel = new TraceSwitch("FileTraceListenerSwitch",
"explanation...");
or
fileTraeLevel.Level = (TraceLevel)section.??? !!
How do i get the level information from the section ??
Thank you in advance.
BR
Peter |
|
|
| Back to top |
|
|
|
| Peter Larsen [CPH]... |
Posted: Wed Oct 14, 2009 4:27 am |
|
|
|
Guest
|
Hi Colbert,
Thank you for your comment.
But, if you changed the level in a app.config, belonging to a running
application, the application does not see the change until the app is
restarted.
Isn't that right ??
BR
Peter
"Colbert Zhou [MSFT]" <colbertz at (no spam) online.microsoft.com> wrote in message
news:xjZM1BySKHA.2084 at (no spam) TK2MSFTNGHUB02.phx.gbl...
Quote: Hello Peter,
As the |
|
|
| Back to top |
|
|
|
| Colbert Zhou [MSFT]... |
Posted: Thu Oct 15, 2009 4:00 am |
|
|
|
Guest
|
Hello Peter,
The new app.Config file is loaded after the RefreshSection calling. It is
just the Trace data does not update. We can call Trace.Refresh to update it.
static void Main(string[] args)
{
TraceSwitch appSwitch = new TraceSwitch("mySwitch", "Switch in
config file");
Console.WriteLine("Trace switch {0} configured as {1}",
appSwitch.DisplayName, appSwitch.Level.ToString());
System.Diagnostics.Debugger.Break();
System.Configuration.ConfigurationManager.RefreshSection("system.diagnostics
");
System.Diagnostics.Trace.Refresh();
Console.WriteLine("Trace switch {0} configured as
{1}",appSwitch.DisplayName, appSwitch.Level.ToString());
}
Please note if you are debugging the codes, the config to modify is
***.vshost.exe.config.
Please give it a try and let me know it works for you!
Best regards,
Ji Zhou
Microsoft Newsgroup Support Team |
|
|
| Back to top |
|
|
|
| Peter Larsen [CPH]... |
Posted: Tue Oct 20, 2009 4:21 am |
|
|
|
Guest
|
Hi Colbert,
Thanks for the reply.
I will look into this monday/tuesday next week where i'm going to work on
the project where i have this problem.
BR
Peter
"Colbert Zhou [MSFT]" <colbertz at (no spam) online.microsoft.com> wrote in message
news:O8n7n5XTKHA.2716 at (no spam) TK2MSFTNGHUB02.phx.gbl...
> Hello Peter, |
|
|
| Back to top |
|
|
|
| Peter Larsen [CPH]... |
Posted: Tue Oct 27, 2009 6:11 am |
|
|
|
Guest
|
Hi Colbert,
I have tried what you suggested and it works.
I think i have missed the refresh method on Trace.
Why is it that "appSettings" is available after RefreshSection() and trace
isn't ??
BR
Peter
"Colbert Zhou [MSFT]" <colbertz at (no spam) online.microsoft.com> wrote in message
news:O8n7n5XTKHA.2716 at (no spam) TK2MSFTNGHUB02.phx.gbl...
Quote: Hello Peter,
The new app.Config file is loaded after the RefreshSection calling. It is |
|
|
| Back to top |
|
|
|
|