Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
App.config updates
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Larsen [CPH]  
View profile  
 More options Oct 9, 10:39 pm
Newsgroups: microsoft.public.dotnet.framework
From: "Peter Larsen [CPH]" <PeterLar...@community.nospam>
Date: Fri, 9 Oct 2009 14:39:05 +0200
Local: Fri, Oct 9 2009 10:39 pm
Subject: App.config updates
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.diagnostic s");
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


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colbert Zhou [MSFT]  
View profile  
 More options Oct 12, 7:43 pm
Newsgroups: microsoft.public.dotnet.framework
From: colbe...@online.microsoft.com (Colbert Zhou [MSFT])
Date: Mon, 12 Oct 2009 09:43:19 GMT
Local: Mon, Oct 12 2009 7:43 pm
Subject: RE: App.config updates
Hello Peter,

As the MSDN documentation says,
(http://msdn.microsoft.com/en-us/library/system.diagnostics.traceswitc...
)
"In your application, you can use the configured switch level by creating a
TraceSwitch with the same name"

So, we can just create a new instance of TraceSwitch that has the same name
as the one in configuration file to access the configured switch. For
example, I have the following part in the app.config,
------------------------------------------------
  <system.diagnostics>
    <switches>
      <add name="mySwitch" value="1" />
    </switches>
  </system.diagnostics>
------------------------------------------------

Then in the application, to get the TraceSwitch level, I just need to use
the following codes,
------------------------------------------------
        private static TraceSwitch appSwitch = new
TraceSwitch("mySwitch","Switch in config file");

        static void Main(string[] args)
        {
            Console.WriteLine("Trace switch {0} configured as
{1}",appSwitch.DisplayName, appSwitch.Level.ToString());
        }
------------------------------------------------

I have tested the above codes and it works fine.

Best regards,
Ji Zhou
Microsoft Managed MSDN Newsgroup Support Team


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Larsen [CPH]  
View profile  
 More options Oct 14, 8:27 pm
Newsgroups: microsoft.public.dotnet.framework
From: "Peter Larsen [CPH]" <PeterLar...@community.nospam>
Date: Wed, 14 Oct 2009 12:27:15 +0200
Local: Wed, Oct 14 2009 8:27 pm
Subject: Re: App.config updates
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]" <colbe...@online.microsoft.com> wrote in message
news:xjZM1BySKHA.2084@TK2MSFTNGHUB02.phx.gbl...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colbert Zhou [MSFT]  
View profile  
 More options Oct 15, 8:00 pm
Newsgroups: microsoft.public.dotnet.framework
From: colbe...@online.microsoft.com (Colbert Zhou [MSFT])
Date: Thu, 15 Oct 2009 10:00:52 GMT
Local: Thurs, Oct 15 2009 8:00 pm
Subject: Re: App.config updates
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.diagnostic s
");
            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


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Larsen [CPH]  
View profile  
 More options Oct 20, 8:21 pm
Newsgroups: microsoft.public.dotnet.framework
From: "Peter Larsen [CPH]" <PeterLar...@community.nospam>
Date: Tue, 20 Oct 2009 12:21:38 +0200
Local: Tues, Oct 20 2009 8:21 pm
Subject: Re: App.config updates
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]" <colbe...@online.microsoft.com> wrote in message
news:O8n7n5XTKHA.2716@TK2MSFTNGHUB02.phx.gbl...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Larsen [CPH]  
View profile  
 More options Oct 27, 11:11 pm
Newsgroups: microsoft.public.dotnet.framework
From: "Peter Larsen [CPH]" <PeterLar...@community.nospam>
Date: Tue, 27 Oct 2009 13:11:55 +0100
Local: Tues, Oct 27 2009 11:11 pm
Subject: Re: App.config updates
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]" <colbe...@online.microsoft.com> wrote in message
news:O8n7n5XTKHA.2716@TK2MSFTNGHUB02.phx.gbl...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google