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

  

原文地址:https://www.cnblogs.com/Zing/p/5212066.html