Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Read the article WCF Tracing FAQs WCF Tracing FAQs[^] which is a good introduction however I would like to override setting in my config file in system.dianostics section

If I have configured my trace listeners in my web.config/ap.config file. How can can I override these programmtically. For example if I have

<source propagateActivity="true" name="System.ServiceModel" switchValue="Off,ActivityTracing">
  <listeners>
    <add type="System.Diagnostics.DefaultTraceListener" name="Default">
      <filter type="" />
    </add>
    <add name="ServiceModelTraceListener">
      <filter type="" />
    </add>
  </listeners>
</source



and I need to change the switchValue to say warning

<source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
  <listeners>
    <add type="System.Diagnostics.DefaultTraceListener" name="Default">
      <filter type="" />
    </add>
    <add name="ServiceModelTraceListener">
      <filter type="" />
    </add>
  </listeners>
</source>


one can simply edit the appropriate config file.
However for end users one does not want them to edit these files.

What one would like is to have these values established from the config files and then have an option within one's application
to alter these settings programmtically so only specific values (switchValue in this case) are changed.
One would normally not want tracing on but if a user has problems the user can set activate the trace to some level and then e-mail back the trace log for analysis.

So one would like:
1. Start application
2. Apllication reads in config file settings.
3. [Optionally read in user preferences from a separate source (file, database etc) and use these to override config file settings]
4. Provide the option for the user to programmtically override some settings while application is running.
5. [Optionally persist user override preferences to another storage mechanism (file, database etc)]

One does not want to edit or persist changes to the original config files. If one needs persist changes then one would have a separate persistant store with overrides and apply any changes after the original config file is processed. However for the most part one would only like a temporary override while the application is running.

Is this possible? :confused:

From what research I have done one can set up these settings programmatically or from a config file. There does not seem to be any information on how to have a hybrid of the two, use the config file to establish base values and then programmatically override some. :sigh:
Posted

That does not sound logical.

Logging especially at a verbose level can be very useful to diagnose what is happening. One wants to the user to be able to escalate logging for a period of time and when the problem has been diagnosed, reduce the logging level down so it does not create unnecessary activity and hard drive usage.

I have no control over what client does at their own site. They may make changes to their network setup or install software that can adversely affect what has been working well for some time.
You get call saying it does not work (even though it has for some time). They quite often outsource their IT support and to get the outsourced IT company to run any diagnostics or even describe what they have done will result in them billing us. We need a diagnositic facility that the user can activate when things go wrong and send us the trace files. We don't need the trace to be active if it is working well.

>> If you want them to have a configurable level, add another logging level yourself which you can fully control.

How do you do this? :confused:

If can do this why have the original logging in place? :sigh:
 
Share this answer
 
Your end users shouldn't be able to switch those kind of settings. If you want them to have a configurable level, add another logging level yourself which you can fully control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900