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();
            }

  • 相关阅读:
    CSS3中background-origin和background-clip的区别
    JavaScript的赋值是引用or复制,及参数传递
    写第一个jquery插件实录
    北大acm1008
    北大acm1007
    北大acm1006
    北大acm1005
    北大acm1004
    团队绩效评估
    第二阶段冲刺第十天
  • 原文地址:https://www.cnblogs.com/Linyb/p/2663054.html
Copyright © 2011-2022 走看看