• C# 利用file打印日志


      public class FaceLog
        {
            public static void AppendInfoLog(string errMsg)
            {
                try
                {
                    string Folder = Main.Instance.AppPath + "\Logs\";
                    string fileName = Folder + "Info_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                    if (!System.IO.Directory.Exists(Folder))
                        System.IO.Directory.CreateDirectory(Folder);
                    if (!File.Exists(fileName))
                        System.IO.File.Create(fileName);
                    using (TextWriter fs = new StreamWriter(fileName, true))
                    {
                        fs.WriteLine("--------------------------" + DateTime.Now.ToString() + "----------------------------------------");
                        fs.WriteLine(errMsg);
                        fs.WriteLine("");
                        fs.WriteLine("");
                        fs.Close();
                        fs.Dispose();
                    }
                }
                catch
                {
                }
            }
            public static void AppendErrorLog(string errMsg)
            {
                try
                {
                    string Folder = Main.Instance.AppPath + "\Logs\";
                    string fileName = Folder + "Error_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                    if (!System.IO.Directory.Exists(Folder))
                        System.IO.Directory.CreateDirectory(Folder);
                    if (!File.Exists(fileName))
                        System.IO.File.Create(fileName);
                    using (TextWriter fs = new StreamWriter(fileName, true))
                    {
                        fs.WriteLine("--------------------------" + DateTime.Now.ToString() + "----------------------------------------");
                        fs.WriteLine(errMsg);
                        fs.WriteLine("");
                        fs.WriteLine("");
                        fs.Close();
                        fs.Dispose();
                    }
                }
                catch
                {
                }
            }
        }
  • 相关阅读:
    生成对抗性网络GAN
    一些程序员好用的网站
    TED演讲积累。
    JQuery$.extend()用法
    jQuery中判断数组
    input标签中的accpet
    gitlab的添加密钥
    Linux—Ubuntu14.0.5 修改gitlab管理员的密码
    Linux—Ubuntu14.0.5安装gitlab
    Linux—Ubuntu14.0.5安装Redis
  • 原文地址:https://www.cnblogs.com/wangboke/p/5854144.html
Copyright © 2020-2023  润新知