1 /// <summary> 2 /// 日志 3 /// </summary> 4 /// <param name="content">文本</param> 5 /// <param name="prefix">文件名前缀,默认log,error,getdata</param> 6 public static void WriteLog(string content, string prefix = "log") 7 { 8 try 9 { 10 var LogPath = AppDomain.CurrentDomain.BaseDirectory + @"ErrorLoglogs"; 11 string filename = LogPath + DateTime.Now.ToString("yyyyMMdd") + ".txt"; 12 content = "----------------------" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "---------------------" + System.Environment.NewLine + content; 13 content += System.Environment.NewLine + System.Environment.NewLine; 14 System.IO.File.AppendAllText(filename, content); 15 } 16 catch (Exception) 17 { 18 } 19 }