2

我在 Elmah 中记录我的错误,ErrorLog.GetDefault因为我想使用 ErrorId。但是,当我这样做时,服务器变量不包含在日志条目中。谁能解释为什么,如果可能的话,如何解决这个问题?

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));
}
4

1 回答 1

5

我能够通过包含HttpContext.Current在 Elmah 错误中来解决这个问题。

var elmahId = ErrorLog.GetDefault(HttpContext.Current).Log(new Error(exception, HttpContext.Current));

我仍然想知道为什么ErrorLog.GetDefault需要 aHttpContext因为它似乎对它没有任何作用。

于 2013-03-28T13:50:38.720 回答