zoukankan      html  css  js  c++  java
  • 动态创建日志文件写日志


    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
  • 相关阅读:
    十大排序算法之选择排序(2)
    十大排序算法之冒泡排序(1)
    2018年年度总结
    敏捷软件开发学习笔记(四)之结构型设计模式
    敏捷软件开发学习笔记(三)之创造型设计模式
    elasticsearch+head+kibana
    闭包函数延迟绑定问题
    初谈dango的post提交csrf设置和文件上传
    浏览器的同源策略,及如可跨域
    socket并发通信的几种方式
  • 原文地址:https://www.cnblogs.com/jinweida/p/1312831.html
Copyright © 2011-2022 走看看