ELMAH - Exception Logging without having HttpContext

前端 未结 4 1449
野的像风
野的像风 2020-12-13 03:40

I tried this solution with Elmah.XmlFileErrorLog but I\'m getting following exception

System.ArgumentNullException was unhandled by user code
  Message=\"Val         


        
4条回答
  •  天命终不由人
    2020-12-13 04:24

    Are you running this code within ASP.NET? Seems like the HttpContext is null and this is causing the ELmah code to throw the exception -the method Elmah.ErrorSignal.FromCurrentContext() would pass HttpContext.Current from what I remember (been awhile since looked into it) to the Elmah.ErrorSignal.FromContext(HttpContext context) method and this seems to be null, which would not normally be the case in Asp.Net hosted stuff.

    Another possibility is that this is occuring outside a request to the server so the HttpContext might be null

提交回复
热议问题