zoukankan      html  css  js  c++  java
  • 设置Log记录

    static void Log(string str, Object o)
            {
                String message = String.Empty;
                if (o.GetType() == typeof(Exception))
                {
                    message = ((Exception)o).Message;
                }
                else
                {
                    message = o.ToString();
                }
    
                string strPath = @"C:Mentoring";
                string fileName = "MentoringMatchLog";
                //得到物理路径中的文件
                string newPath = Path.Combine(strPath);
                if (!Directory.Exists(newPath)) //若文件夹不存在则新建文件夹   
                {
                    Directory.CreateDirectory(newPath); //新建文件夹  
                }
    
                if (System.IO.File.Exists(strPath + "\" + fileName + ".txt"))
                {
                    using (System.IO.StreamWriter sw = new System.IO.StreamWriter(strPath + "\" + fileName + ".txt", true))
                    {
                        sw.WriteLine("DateTime:" + DateTime.Now + " ; " + str + ":" + message);
                        sw.Close();
                    }
                }
                else
                {
                    System.IO.File.Create(strPath + "\" + fileName + ".txt").Close();
                    using (System.IO.StreamWriter sw = new System.IO.StreamWriter(strPath + "\" + fileName + ".txt", true))
                    {
                        sw.WriteLine("DateTime:" + DateTime.Now + " ; " + str + ":" + message);
                        sw.Close();
                    }
                }
    
            }
  • 相关阅读:
    页面滚动
    代码提交报错
    校区下部门 及校区下员工
    表查询
    Jemeter命令执行
    抓包工具
    彻底解决mac下terminal路径显示问题
    PHP 性能分析第二篇: Xhgui In-Depth
    PHP 性能分析第一篇: Intro to Xhprof & Xhgui
    phpredis pipeline
  • 原文地址:https://www.cnblogs.com/learning-life/p/10722920.html
Copyright © 2011-2022 走看看