• 动态创建日志文件写日志



    private static string logpath = System.Windows.Forms.Application.StartupPath;
            
    public static void WriteLog(string businessContent, string flieName, string functionName, string description, Wapdm.Utility.Enum.LogLevel level)
            {
                
    #region          

                
    try
                {
                    
    string strDumpPath = logpath+"\\log";
                    
    lock (typeof(LogWrite))
                    {
                        
    if (!Directory.Exists(strDumpPath))
                        {
                            Directory.CreateDirectory(strDumpPath);
                        }
                        
    using (StreamWriter sw = new StreamWriter(strDumpPath + "\\" + DateTime.Now.ToString("yyyyMMdd"+ ".log"true))
                        {
                            
    string context = "业务:" + businessContent + ";\r\n文件名:" + flieName + ";\r\n函数名:" + functionName + ";\r\n描述:" + description;
                            sw.WriteLine(DateTime.Now.ToString());
                            sw.WriteLine(context);
                            sw.WriteLine(
    " ");
                            sw.WriteLine(
    "-----------------------End---------------------");
                        }
                    }

                }
                
    catch
                {
                    
                }
                
    #endregion
  • 相关阅读:
    Linux高级命令-sort、uniq、 cut、sed、grep、find、awk
    Linux netstat命令详解
    linux的top命令
    sysctl -P 报错解决办法
    Linux的用户切换、修改用户的用户名和密码
    后台启动
    查询员工表薪资第二高的人的信息
    警察抓小偷
    汉诺塔
    mysql中给查询出的结果集添加自增序号
  • 原文地址:https://www.cnblogs.com/jinweida/p/1312831.html
Copyright © 2020-2023  润新知