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();
}
}
}
}