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();
                    }
                   
            }
        }
    }
  • 相关阅读:
    HDU 6043
    HDU 6033
    HDU 6041
    HDU 6050
    HDU 6053
    HDU 6055
    HDU 6045
    HDU 6044
    HDU 6040
    ZUFE 1035 字符宽度编码(字符串)
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3075954.html
Copyright © 2011-2022 走看看