using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Configuration;
///
/// Summary description for clsExceptionHandling
///
public class ExceptionHandling
{
public ExceptionHandling()
{
//
// TODO: Add constructor logic here
//
}
///
/// Writes error occured in log file,if log file does not exist,it creates the file first.
///
/// Exception
public static void Write(Exception exception)
{
string logFile = String.Empty;
StreamWriter logWriter;
try
{
logFile = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["ErrorLog"].ToString());
if (File.Exists(logFile))
logWriter = File.AppendText(logFile);
else
logWriter = File.CreateText(logFile);
logWriter.WriteLine("=>" + DateTime.Now + " " + " An Error occured : " +
exception.StackTrace + " Message : " + exception.InnerException + "\n\n");
logWriter.Close();
throw exception;
}
catch (Exception e)
{
throw e;
}
finally
{
throw exception;
}
}
}