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
  • 相关阅读:
    语言精粹【摘要】
    【转】一个Java程序员应该掌握的10项技能
    比较有用的网址
    推荐一些国内的Jquery CDN免费服务
    CSS3动画【归纳总结】
    scrollTo与border结合使用的小玩意
    aria-label及aria-labelledby应用//////////[信息无障碍产品联盟]
    aria初探(一)
    没有this的JavaScript
    Front-end Job Interview Questions
  • 原文地址:https://www.cnblogs.com/jinweida/p/1312831.html
Copyright © 2011-2022 走看看