public void EatDinner(string appetizer, string mainCourse, string dessert)
{
try
{
// Code
}
catch (Exception ex)
{
Logger.Log("Error in EatDinner", ex);
return;
}
}
When an exception occurs in a specific method, what should I be logging?
I see a lot of the above in the code I work with. In these cases, I always have to talk to the person who experienced the error to find out what they were doing, step through the code, and try to reproduce the error.
Is there any best practices or ways I can minimize all this extra work? Should I log the parameters in each method like this?
Logger.Log("Params: " + appetizer + "," + mainCourse + "," + dessert, ex);
Is there a better way to log the current environment? If I do it this way, will I need to write out all this stuff for each method I have in my application? Are there any best practices concerning scenarios like this?