I have a ASP.Net MVC Web Application hosted in Azure Web Service. I need to log Exceptions to Application Log.
Later I want to check and review what kind of exceptions happened.
How can I do it?
If by exceptions you mean those caught inside a try-catch then you could do;
Follow the steps mentioned here, you need to toggle this setting on your Azure web app;
Your App > App Service Logs > Turn On Application Logging (FileSystem)
Then use the code below; Trace.Information(), Trace.Warning(), Trace.Error()
using System.Diagnostics;
public ActionResult sample(){
try{
Trace.Information("Hello World!");
}catch(exception e){
Trace.Error(e.Message);
}
}