c#记录日志的方法

/// <summary>
       /// 生成日志
       /// </summary>
       /// <param name="text"></param>
       public static void WriteLog(string text)
       {
           string logPath = System.AppDomain.CurrentDomain.BaseDirectory + "XiuJiaMontyly.log";
           using (StreamWriter sw = File.AppendText(logPath))
           {
               sw.WriteLine("消息:" + text);
               sw.WriteLine("时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
               sw.WriteLine("**************************************************");
               sw.WriteLine();
               sw.Flush();
               sw.Close();
               sw.Dispose();
           }
       }

  

猜你喜欢

转载自www.cnblogs.com/yachao1120/p/9497937.html