【发布时间】:2020-11-20 02:32:42
【问题描述】:
我的应用程序将其跟踪源配置如下:
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;
应用程序始终使用此跟踪源来跟踪事件。 请注意,SourceLevels.Information 在跟踪开关中是硬编码的。 现在我需要将跟踪开关级别更改为详细。是否可以通过 app.config 文件完成?我尝试了许多 xml-configs 但失败了。注意我不能只更改 app.config 的源代码。
【问题讨论】:
标签: c# .net logging app-config