| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Core.Mes.Client.Comm.Tool
- {
- public class LogHelper
- {
- #region 记录系统运行日志
- /// <summary>
- /// 写日志
- /// </summary>
- /// <param name="strModelName">模块名称</param>
- /// <param name="str">日志</param>
- public static void WriteLogs(string strModelName, string str)
- {
- try
- {
- string m_szRunPath = System.Environment.CurrentDirectory.ToString();
- string strLogPath = m_szRunPath + "\\log";
- if (!(System.IO.Directory.Exists(strLogPath)))
- {
- System.IO.Directory.CreateDirectory(strLogPath);
- }
- strLogPath = m_szRunPath + "\\log\\" + strModelName + "_" + System.DateTime.Now.ToString("yyyyMMddhh") + ".log";
- System.IO.TextWriter tw = new System.IO.StreamWriter(strLogPath, true);
- //tw.Encoding = new e
- tw.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- tw.WriteLine(str);
- tw.WriteLine("\r\n");
- tw.Close();
- tw.Dispose();
- }
- catch
- {
- //throw;
- }
- }
- #endregion
- }
- }
|