123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.IO;
- using UAS_MES.Entity;
- namespace UAS_MES.PublicMethod
- {
- class LogManager
- {
- public static string LogAddress = SystemInf.LogFolder;
- /// <summary>
- /// 记录操作
- /// </summary>
- /// <param name="Message"></param>
- public static void DoLog(string Message)
- {
- try
- {
- StreamWriter sw = File.AppendText(LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
- sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n");
- sw.WriteLine("【消息】" + Message + "\n");
- sw.WriteLine("---------------------------------------------------------------------------------------------------------------");
- sw.Close();
- }
- catch (Exception) { }
- }
- /// <summary>
- /// 记录操作和SQL
- /// </summary>
- /// <param name="Message"></param>
- /// <param name="SQL"></param>
- public static void DoLog(string Message, string SQL)
- {
- try
- {
- StreamWriter sw = File.AppendText(LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
- sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n");
- sw.WriteLine("【消息】" + Message + "\n");
- sw.WriteLine("【SQL】" + SQL + "\n");
- sw.WriteLine("---------------------------------------------------------------------------------------------------------------");
- sw.Close();
- }
- catch (Exception) { }
- }
- /// <summary>
- /// 记录SQL
- /// </summary>
- /// <param name="SQL"></param>
- public static void DoSQLLog(string SQL)
- {
- try
- {
- StreamWriter sw = File.AppendText(LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
- sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n");
- sw.WriteLine("【SQL】" + SQL + "\n");
- sw.WriteLine("---------------------------------------------------------------------------------------------------------------");
- sw.Close();
- }
- catch (Exception) { }
- }
- }
- }
|