zoukankan      html  css  js  c++  java
  • 详细的日志文件

    public static void ErrorLog(Exception ex)
    {
    string FilePath = AppDomain.CurrentDomain.BaseDirectory+"ErrorLog.txt";/bin/Debug

            StringBuilder msg = new StringBuilder();
            msg.Append("*************************************** 
    ");
            msg.AppendFormat(" 异常发生时间: {0} 
    ", DateTime.Now);
            msg.AppendFormat(" 异常类型: {0} 
    ", ex.HResult);
            msg.AppendFormat(" 导致当前异常的 Exception 实例: {0} 
    ", ex.InnerException);
            msg.AppendFormat(" 导致异常的应用程序或对象的名称: {0} 
    ", ex.Source);
            msg.AppendFormat(" 引发异常的方法: {0} 
    ", ex.TargetSite);
            msg.AppendFormat(" 异常堆栈信息: {0} 
    ", ex.StackTrace);
            msg.AppendFormat(" 异常消息: {0} 
    ", ex.Message);
            msg.Append("***************************************");
    
            try
            {
                if (File.Exists(FilePath))
                {
                    using (StreamWriter tw = File.AppendText(FilePath))
                    {
                        tw.WriteLine(msg.ToString());
                    }
                }
                else
                {
                    TextWriter tw = new StreamWriter(FilePath);
                    tw.WriteLine(msg.ToString());
                    tw.Flush();
                    tw.Close();
                    tw = null;
                }
            }
            catch (Exception)
            {
                Console.ReadKey();
            }
    
        }
  • 相关阅读:
    iOS6后的内存警告处理
    key things of ARC
    敏捷软件开发Note
    ViewController的属性
    sizeToFit & sizeThatFits
    iOS静态库的制作与引用
    xcode添加build phase
    什么是HUD
    xcode中的预定义宏
    管理授权&管理决策&管理组织&管理目标
  • 原文地址:https://www.cnblogs.com/zmldz/p/14518879.html
Copyright © 2011-2022 走看看