zoukankan      html  css  js  c++  java
  • TextWriter记录日志

     1 public static void SaveExceptionLog(Exception ex, string methodName)
     2 {
     3   using (TextWriter tw = new StreamWriter(new System.Web.UI.Page().Server.MapPath("~/App_Data/LogErrorWXHandler_" + DateTime.Now.Ticks + ".txt")))
     4   {
     5     //StackTrace stackTrace = new StackTrace(true);//也可以使用这种方式
     6     //string methodName = stackTrace.GetFrame(1).GetMethod().Name.ToString();
     7     tw.WriteLine(methodName);
     8     tw.WriteLine(ex.Message);
     9     tw.WriteLine(ex.Source + ":" + ex.GetType() + "," + ex.StackTrace);
    10     tw.WriteLine(ex.InnerException.Message);
    11     tw.Flush();
    12     tw.Close();
    13   }
    14 }
  • 相关阅读:
    os模块
    sys模块
    psutil模块
    subprocess模块
    time模块
    argparse模块
    tcp端口扫描(python多线程)
    基于http的软件仓库
    SRE思想
    redis哨兵模式
  • 原文地址:https://www.cnblogs.com/hzz521/p/5145521.html
Copyright © 2011-2022 走看看