I Log my errors in Elmah using ErrorLog.GetDefault
because I want to use the ErrorId. However when I do this the Server Variables are not included in the log entry. Could anyone explain why and if possible, how to fix this?
public void LogExceptionToElmah(Exception exception)
{
//Includes Server Variables
ErrorSignal.FromContext(HttpContext.Current).Raise(exception);
//Does not include Server Variables
var elmahId = Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Error(exception));
}
I was able to solve this by including HttpContext.Current
into the Elmah Error.
var elmahId = ErrorLog.GetDefault(HttpContext.Current).Log(new Error(exception, HttpContext.Current));
I still wonder why the ErrorLog.GetDefault
requires a HttpContext
as it doesn't seem to do anything with it.