c#简单的调试信息、日志信息输出

public static void ErrorLog(string mssg)
        {
            string FilePath = "D:/logs/ErrorLog.txt";
            try
            {
                if (System.IO.File.Exists(FilePath))
                {
                    using (StreamWriter tw = System.IO.File.AppendText(FilePath))
                    {
                        tw.WriteLine(DateTime.Now.ToString() + "> " + mssg);
                    }  //END using

                }  //END if
                else
                {
                    StreamWriter tw = new StreamWriter(FilePath);
                    tw.WriteLine(DateTime.Now.ToString() + "> " + mssg);
                    tw.Flush();
                    tw.Close();
                    tw = null;
                }  //END else

            }  //END Try
            catch (Exception ex)
            { } //END Catch   

        }  // END ErrorLog

  

posted @ 2016-02-24 10:32  朝闲  阅读(1234)  评论(0编辑  收藏  举报