I have app that configures its trace source as follows:
var traceSource = new TraceSource("MyTraceSource");
traceSource.Switch = new SourceSwitch("MyTraceSwitch") { **Level = SourceLevels.Information** };
var traceListener = new TextWriterTraceListener(logFilePath);
traceListener.TraceOutputOptions = TraceOptions.DateTime;
traceSource.Listeners.Clear();
traceSource.Listeners.Add(traceListener);
Trace.AutoFlush = true;
The app always uses this trace source to trace events. Please note that SourceLevels.Information is hardcoded in trace switch. Now I need to change the trace switch level to Verbose. Is it possible to accomplish via app.config file? I tried many xml-configs but failed. Note I cannot change the source code only app.config.
I'm not sure if you are searching for something like this, but I've used once the following xml configuration to: change the trace switch level to Verbose.
(App-Config)
<configuration>
<system.diagnostics>
<switches>
<add name="AppTraceLevel" value="4" /> //4 = Verbose
</switches>
// Here would be the Trace Tag with the Listeners (not important for your question)
</system.diagnostics>
</configuration>
Maybe it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With