//紀錄Log方法

private void Log(string msg)
{
    System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + @"\log.txt", DateTime.Now + "\t" + msg + Environment.NewLine);
}

//.net 2.0 Log記錄寫法

string path = AppDomain.CurrentDomain.BaseDirectory + @"\log.txt";
using (StreamWriter sw = File.AppendText(path)) 
{                    
    sw.WriteLine(DateTime.Now.ToString() + "  " + ex.ToString());
}

 

創作者介紹
創作者 隨手筆記 的頭像
芭樂養樂多

隨手筆記

芭樂養樂多 發表在 痞客邦 留言(0) 人氣( 1231 )