关于System.Diagnostics.Trace类的问题

/// /// The main entry point for the application. ///

[STAThread]

 public static void Main()

{

 try {

// setup generic exception handler...

SWF.Application.ThreadException += new ST.ThreadExceptionEventHandler(App.OnAppException);

// setup cleanup routine for normal app shutdown...

SWF.Application.ThreadExit += new System.EventHandler(App.OnAppExit);

// when app starts, delete the previous log file (if any) string logfile = System.AppDomain.CurrentDomain.BaseDirectory + "AppLog.txt"; System.IO.TextWriter log = new System.IO.StreamWriter(logfile);

 if (Globals.Trace) // then also send trace output to log file? {

System.Diagnostics.TextWriterTraceListener logger; logger = new System.Diagnostics.TextWriterTraceListener(log); System.Diagnostics.Trace.Listeners.Add(logger);

System.Diagnostics.Trace.Write("App starting: " + DateTime.Now); } SWF.Application.Run(new Form1()); }

catch(Exception ex)

{ OnAppException(null, new ST.ThreadExceptionEventArgs(ex)); }

 

以上是利用Trace类来记录程序运行日志的代码,可每次当应用程序重启后,AppLog.txt文件里以前的内容就被覆盖了。谁知道这个问题怎么解决呢?

智慧大石
浏览 707回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP