문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top