private static void InitializeLogging() { const string TEMPORARY_DIRECTORY_NAME = "Temp"; const string DEBUG_LOG_NAME = "DebugLog.txt"; const int MAX_LOG_LENGTH_BYTES = 1 * 1024 * 1024; const int MAX_BACKUP_FILES = 10; string temporaryDir = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), TEMPORARY_DIRECTORY_NAME); string logFileName = Path.Combine(temporaryDir, DEBUG_LOG_NAME); // Create the directory if it doesn't already exist. if (!Directory.Exists(temporaryDir)) { Directory.CreateDirectory(temporaryDir); } // Setup a trace listener to our log file! var fs = new FileStreamWithBackup(logFileName, MAX_LOG_LENGTH_BYTES, MAX_BACKUP_FILES, FileMode.Append); fs.CanSplitData = false; var listener = new TextWriterTraceListenerWithTime(fs); Trace.Listeners.Add(listener); }
static void Main() { Thread thrd = Thread.CurrentThread; thrd.Priority = ThreadPriority.AboveNormal; Trace.WriteLine("Priority is now: " + thrd.Priority); FileStreamWithBackup fs = new FileStreamWithBackup("quavs.gs.log", 2000000000, 10, FileMode.Append); fs.CanSplitData = false; TextWriterTraceListener listener = new TextWriterTraceListener(fs); Trace.AutoFlush = true; Trace.Listeners.Add(listener); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }