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
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