Beispiel #1
0
 /// <summary>
 /// 写文本日志
 /// </summary>
 /// <param name="Content"></param>
 public static void WriteTxtLog(string Content)
 {
     try
     {
         string fileName = System.AppDomain.CurrentDomain.BaseDirectory;
         if (!fileName.EndsWith("\\"))
         {
             fileName += "\\";
         }
         fileName += "Log\\";
         fileName += System.DateTime.Now.ToString("yyyy-MM-dd-HH") + ".txt";
         string br = "\r\n";
         string content = Content;
         FileIO fIO = new FileIO();
         fIO.OpenWriteFile(fileName);
         fIO.WriteLine(content + br + br + "*******************************************************" + br);
         fIO.CloseWriteFile();
     }
     catch
     {
     }
 }
Beispiel #2
0
 /// <summary>
 /// 写文本日志
 /// </summary>
 /// <param name="Ex"></param>
 public static void WriteTxtLog(Exception Ex)
 {
     try
     {
         string fileName = System.AppDomain.CurrentDomain.BaseDirectory;
         if (!fileName.EndsWith("\\"))
         {
             fileName += "\\";
         }
         fileName += "Log\\";
         fileName += System.DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
         string blank = "    ";
         string br = "\r\n";
         string content = string.Empty;
         //content += "客户端IP:" + ClientIP;
         //content += br + "客户端操作系统:" + ClientPlatform;
         //content += br + "客户端浏览器:" + ClientBrowser;
         //content += br + "服务器计算机名:" + System.Net.Dns.GetHostName();
         //content += br + "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         //content += br + "引发页面:" + System.Web.HttpContext.Current.Request.Url.ToString();
         //content += br + "异常对象:" + Ex.Source;
         //content += br + "异常信息:" + Ex.Message;
         //content += br + "异常方法:" + Ex.TargetSite;
         //content += br + "错误详细信息:";
         content += br + blank + Ex.ToString();
         FileIO fIO = new FileIO();
         fIO.OpenWriteFile(fileName);
         fIO.WriteLine(content + br + br + "*******************************************************" + br);
         fIO.CloseWriteFile();
     }
     catch
     {
     }
 }
Beispiel #3
0
 /// <summary>
 /// 写文本日志
 /// </summary>
 /// <param name="Content"></param>
 /// <param name="logFilePath"></param>
 public static void WriteTxtLog(string Content, string logFilePath)
 {
     try
     {
         string fileName = logFilePath;
         string br = "\r\n";
         string content = Content;
         FileIO fIO = new FileIO();
         fIO.OpenWriteFile(fileName);
         fIO.WriteLine(content + br + br + "*******************************************************" + br);
         fIO.CloseWriteFile();
     }
     catch
     {
     }
 }