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();
           }
       }

  

posted @ 2018-08-18 17:33  小猫钓鱼吃鱼  阅读(1338)  评论(0编辑  收藏  举报