Click here to Skip to main content
15,668,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am maintaining text file to store errors occurred into application using OnException method in BaseController. It stores error message and stack trace but stack trace is too long i want only line number and page from it..is it possible..how to do it
//code in Base Cotroller
C#
protected override void OnException(ExceptionContext filterContext)
 {
base.OnException(filterContext);
this.SaveLog(filterContext.Exception);
}

 private void SaveLog(Exception e)
 {
 string filepath = AppDomain.CurrentDomain.BaseDirectory;
                string logFilePath = filepath + @"logs\error\log.txt";
 using (StreamWriter sw = System.IO.File.AppendText(logFilePath))
{
sw.WriteLine("Message: " + e.Message);
sw.WriteLine("StackTrace:"+ e.StackTrace);
}
sw.Close();
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900