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
  • 相关阅读:
    将自己写的经常复用的类封装成dll/lib的方法
    Mat 和 CvMat,IplImage相互转化
    制作VB安装程序问答(Package & Deployment)
    NTDDI_VERSION,_WIN32_WINNT,WINVER,_WIN32_IE定义宏的含义
    解决"cvCreateVideoWriter保存视频帧压缩格式只能用1"的问题
    100条道理,看完后请留下你的感言
    世界上最著名的24幅奇图
    字节对齐
    齐次坐标的理解
    在OpenCV中自适应确定canny算法的分割门限
  • 原文地址:https://www.cnblogs.com/jinweida/p/1312831.html
Copyright © 2011-2022 走看看