Click here to Skip to main content
14,934,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Can any one please tell me how to record all errors in a log file using enterprise library 5 in a mvc 5 application?
In web.config i have changed the logCategory="Trace" then tracingenabled="True" and so on.
In global.asax.cs,
protected void Application_Error(object sender, EventArgs e)
{
//uncomment in order to bypass logging when running locally.
//if (!Request.IsLocal)
//{
Exception ex = Server.GetLastError();
if (ex is HttpUnhandledException && ex.InnerException != null)
{
ex = ex.InnerException;
}

if (ex != null)
{

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.
ExceptionPolicy.HandleException(ex, "General Policy");
Server.ClearError();

Response.Redirect("~/Utility/ErrorPage.htm");
}
}
So here i want to write the exception caught to a log file.
Thanks in Advance!!!
Posted
Comments
Jameel VM 3-Jun-15 15:15pm
   
did you try elmah?
sai sruthi 4-Jun-15 2:00am
   
Not so, but i want this exception handling to happen in global.asax.cs file

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