My ASP.NET web application's back-end is throwing an exception while in production (but not when debugging locally).
Ideally, I'd like to output the exception to a text file which can then be read. This is what I've tried so far:
catch (Exception ex)
{
string exceptionString = ex.ToString();
string errorLogPath = HttpContext.Current.Server.MapPath("~/Server/LogFiles");
StreamWriter sw = new StreamWriter(errorLogPath + '\\' + "logs.txt", true);
sw.WriteLine(exceptionString);
sw.Close();
}
When I go to the logs.txt file there's nothing there. I'm pretty sure that there's an Exception being caught, so I don't see why it's not been written to the text file. Perhaps my code is wrong?
What are the best ways to view back-end Exceptions thrown in production without attaching a debugger?