| | |
| | | namespace MESApplication; |
| | | namespace MESApplication.Filter; |
| | | |
| | | public class ErrorLog |
| | | { |
| | | private static string DirectoryPath = AppDomain.CurrentDomain.BaseDirectory; |
| | | private static readonly string DirectoryPath = |
| | | AppDomain.CurrentDomain.BaseDirectory; |
| | | |
| | | /// <summary> |
| | | /// 写入操作日志到文件中 |
| | | /// 写入操作日志到文件中 |
| | | /// </summary> |
| | | /// <param name="moduleName">模块名字</param> |
| | | /// <param name="message">错误文本信息</param> |
| | |
| | | // 如果目录不存在,则新建文件夹 |
| | | Directory.CreateDirectory(directoryPath); |
| | | |
| | | var filePath = directoryPath + $@"\{DateTime.Now.ToString("yyyyMMddHH")}.log"; // 目标文件路径 |
| | | var filePath = directoryPath + |
| | | $@"\{DateTime.Now.ToString("yyyyMMddHH")}.log"; // 目标文件路径 |
| | | |
| | | if (!File.Exists(filePath)) |
| | | // 如果文件不存在,则创建文件 |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 写入操作日志到文件中 |
| | | /// 写入操作日志到文件中 |
| | | /// </summary> |
| | | /// <param name="moduleName">模块名字</param> |
| | | /// <param name="ex">异常</param> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 写入过程数据或说明到文件中,以便跟踪 |
| | | /// 写入过程数据或说明到文件中,以便跟踪 |
| | | /// </summary> |
| | | /// <param name="moduleName">模块名字</param> |
| | | /// <param name="ex">异常</param> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 文本写入 |
| | | /// 文本写入 |
| | | /// </summary> |
| | | /// <param name="logMessage"></param> |
| | | private static void LogToFile(string logFilePath, string logMessage) |