zoukankan      html  css  js  c++  java
  • 记录系统日志方法

            private static void SaveLog(string log,string ex)
            {
                string strCurPath = AppDomain.CurrentDomain.BaseDirectory;
                string strErrorLogPath = Path.Combine(strCurPath, "ErrorLog");
                string strErrorLogFile = Path.Combine(strErrorLogPath, "SendEmailLog.log");
                if (!Directory.Exists(strErrorLogPath))
                {
                    Directory.CreateDirectory(strErrorLogPath);
                }
                var fs = new FileStream(strErrorLogFile, FileMode.OpenOrCreate);
                var streamWriter = new StreamWriter(fs);
                streamWriter.BaseStream.Seek(0, SeekOrigin.End);
                streamWriter.WriteLine("系统记录时间:[" + DateTime.Now + "]");
                streamWriter.WriteLine("事件 :"+log);
                streamWriter.WriteLine("错误日志:"+ex);
                streamWriter.WriteLine("");
                streamWriter.Flush();
                streamWriter.Close();
                fs.Close();
            }

  • 相关阅读:
    fedora 27
    Python3 字符串操作
    python3 使用matplotlib画图问题
    Python3 移动文件——合集
    MySQL开放外部链接
    python之csv操作问题
    Question
    17-12-21
    python之List排序
    ubuntu版的sublime-text3输入中文问题
  • 原文地址:https://www.cnblogs.com/Linyb/p/2663054.html
Copyright © 2011-2022 走看看