ashok kallagunta

ashok kallagunta

  • NA
  • 118
  • 19.5k

How to create error log in MVC 5

May 30 2017 3:28 AM
I have created a project in MVC5, I want to create an error log for same.
 
is there any way that we can get detailed information about the error. 
 
as of now, i am catching exception like below. 
 
catch (Exception Ex)
{
mailobj.SendMail(
this.ControllerContext.RouteData.Values["controller"].ToString(),
this.ControllerContext.RouteData.Values["action"].ToString(),
Convert.ToString(Ex.Message.Replace("<", "").Replace(">", "").ToString()),
Convert.ToString(Ex.HelpLink),
Convert.ToString(Ex.Source),
Convert.ToString(Ex.StackTrace),
Convert.ToString(Ex.TargetSite));
return Json("error in the system.!", JsonRequestBehavior.AllowGet);
}
 
hear send mail will send mail to admin about error.
 
but the problem is, I could not able to get complete details about the error for example, if you get error message like "Object reference not set to an instance of an object." I want to to what is the parameter value to get this data.
 
Is there any easy way that we can track the errors in the system.
  
 
 
 

Answers (3)