TraceSwitch - How to turn trace on/off in config file based on user data

185 views Asked by At

I wanted to turn on trace for some user data, for example a specific flight number, or a specific trading partner. Would I create a custom switch class, then read some appSetting variables to determine which user data turns the trace on and off?

<configuration>  
  <system.diagnostics>  
    <switches>  
      <add name="mySwitch" value="1"/>  
    </switches>  
  </system.diagnostics>  
  <appSettings>
      <add key="Partner" value="ABCD" />
      <add key="Partner" value="WXYZ" />
   </appSettings>
</configuration>  

Or is there a way to define additional parms to the switch itself?

<configuration>  
  <system.diagnostics>  
    <switches>  
      <add name="mySwitch" value="1" parnersList="ABCD,WXYZ" />  
    </switches>  
  </system.diagnostics>  
</configuration> 
1

There are 1 answers

0
Arno Peters On

It does not seem possible to add additional parameters to a switch, so I think you should go with your first option.