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
  • 相关阅读:
    【转】测试驱动开发
    【转】什么是“脚本语言”
    【转】“解决问题”与“消灭问题”
    【转】程序语言的常见设计错误(1)
    【转】解密“设计模式”
    【转】所谓软件工程
    【转】清华梦的粉碎
    算法知识目录整理
    买书不读是一种什么病?
    Linux 下socket通信终极指南(附TCP、UDP完整代码)
  • 原文地址:https://www.cnblogs.com/jinweida/p/1312831.html
Copyright © 2011-2022 走看看