title: .NET Trace to a file not working
body: <p>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. </p>
  
  <p>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.</p>
  
  <p>My trace code looks like:</p>
  
  <pre><code>internal static void traceWarning(string message)
  {
      if (!traceEnabled)
      {
          traceEnabled = true;
          Trace.Listeners.Add(new TextWriterTraceListener(@"C:\GMS2Trace.log"));
      }
  
      Trace.TraceWarning(getTimeStamp() + " " + message);
  }
  </code></pre>
  
  <p>Is it a problem with the location of the trace file, or something else?</p>