Write logs in Visual Studio 2008

2019-05-23 12:15发布

I am writing application on C++ .NET in Visual Studio 2008. I want to ask if there is standard function for writing logs ?

Edited

it mean I can write such code and where I can see output logs ?

#ifdef DEBUG
Trace::Write("Message", "Category"); 
#endif

1条回答
乱世女痞
2楼-- · 2019-05-23 12:54
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

查看更多
登录 后发表回答