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

  • 相关阅读:
    Java类与对象
    读《大道至简——团队缺乏的不只是管理》有感
    java课后作业
    c++ 创建单项链表
    c++ 结构指针和双向链表
    c++ 自定义数据结构运用
    c++ 时间函数和结构化数据
    c++ 结束程序的几种方式
    c++ main函数的参数
    c++ 参数个数可变的函数
  • 原文地址:https://www.cnblogs.com/Linyb/p/2663054.html
Copyright © 2011-2022 走看看