且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将跟踪输出重定向到控制台

更新时间:2023-12-05 13:03:58

您可以将以下内容添加到您的 exe 的 .config 文件中.

You can add the following to your exe's .config file.

<?xml version="1.0"?>
<configuration>
    <system.diagnostics>
        <trace autoflush="true">
            <listeners>
                <add name="logListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="cat.log" />
                <add name="consoleListener" type="System.Diagnostics.ConsoleTraceListener"/>
            </listeners>
        </trace>
    </system.diagnostics>
</configuration>

我也包含了 TextWriter,以防您有兴趣登录到文件.

I included the TextWriter as well, in case you're interested in logging to a file.