I am trying to track strange things going on in my Windows Forms application with a TextWriterTraceListener pointed to a file location. I have it set up so that the first time the application needs to trace something during the run of the program, it creates the trace listener and registers it.
However, it looks like the trace file is not getting created at all, nothing showed up at C:\GMS2Trace.log. I have verified that the program has reached parts of the code that call the trace method.
My trace code looks like:
internal static void traceWarning(string message)
traceEnabled = true;
Trace.TraceWarning(getTimeStamp() + " " + message);
You can configure it all from app.config and just use:
Example from one of my projects:
<system.diagnostics> <trace autoflush="true" indentsize="4"> <listeners> <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="log.log" /> <remove name="Default" /> </listeners> </trace> </system.diagnostics>
Remember though that all Console.Writeline allso ends up in the file