zoukankan      html  css  js  c++  java
  • ErrHandler

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.Globalization;
    namespace ADM.ProgressMonitor.DataObjects
    {
        public class ErrHandler
        {
            public static void WriteError(Exception error)
            {
                    string basepath = Path.Combine(HttpContext.Current.Server.MapPath("~/")+"/Error");
                    string date = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                    string path = Path.Combine(basepath,  date+ ".txt");
                    if (!File.Exists(path))
                    {
                        File.Create(path).Close();
                    }
                    using (StreamWriter w = File.AppendText(path))
                    {
                        w.WriteLine("Error log:");
                        w.WriteLine("Error Time:"+DateTime.Now);
                        w.WriteLine("Error TargetSite:" + error.TargetSite);
                        w.WriteLine("Error Message:" + error.Message);
                        w.WriteLine("Error StackTrace" + error.StackTrace);
                        w.WriteLine("-----------------------------------------------------------------------------------------------------------------------");
                        w.Flush();
                        w.Close();
                    }
                   
            }
        }
    }
  • 相关阅读:
    sharepoint JQ获取List列表的值
    微信修改域名回掉
    input设置只读
    MVC-AJAX-JSON
    sharepoint添加子网站
    sharepoint打开解决方案库
    前台获取参数值
    SQL查看表结构以及表说明
    JQ获取对象属性值
    bootstrap table样式
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3075954.html
Copyright © 2011-2022 走看看