using System; using System.IO; using System.Diagnostics; class MainClass { [STAThread] static void Main(string[] args) { FileStream Log = new FileStream("Log.txt", FileMode.OpenOrCreate); Trace.Listeners.Add(new TextWriterTraceListener(Log)); Trace.WriteLine("My Trace String To Log File"); Trace.Flush(); Log.Close(); } }