Write logs in Visual Studio 2008

别等时光非礼了梦想. 提交于 2019-12-06 13:22:08
Teoman Soygul
Trace::Write("Message", "Category"); 
Debug::Write("Message", "Category"); // Same thing as #ifdef DEBUG Trace::Write(...)

is pretty much the prebuilt logging facility. To get the output to a file, append the below configuration to your app.config file, all the output will be written to c:\myListener.log:

<configuration>
<system.diagnostics>
  <trace autoflush="false" indentsize="4">
    <listeners>
      <remove name="Default" />
      <add name="myListener"
           type="System.Diagnostics.TextWriterTraceListener"
           initializeData="c:\myListener.log" />
    </listeners>
  </trace>
</system.diagnostics>
</configuration>

Ref: How to: Create and Initialize Trace Listeners

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!