【问题标题】:Activating logging for a Winform Application激活 Winform 应用程序的日志记录
【发布时间】:2013-10-04 00:48:07
【问题描述】:

我遇到了这个:Winforms logging framework

但是,我无法让它工作。

在 app.config 中,我有以下内容:

<system.diagnostics>
    <trace autoflush="false" indentsize="4">
      <listeners>
        <add name="yourName" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\mylogfile.txt" />
      </listeners>
    </trace>
</system.diagnostics

在我的代码中,我将以下内容写入日志文件:

Trace.Write("test");
Trace.TraceError("There's been an error captain: {0}", e);
Trace.TraceWarning("The system broke but don't worry.");
Trace.TraceInformation("Starting up the engines.");

文件已创建。但是没有任何东西被写入。跟踪已在 Visual Studio 中打开。

不确定这里缺少什么。

【问题讨论】:

    标签: c# .net winforms logging trace


    【解决方案1】:

    您已关闭自动刷新。尝试将 autoflush 设置为 true 或在代码示例的末尾调用 Trace.Flush

    【讨论】:

      猜你喜欢
      • 2015-12-24
      • 1970-01-01
      • 2018-04-10
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多