ELMAH - Exception Logging without having HttpContext

前端 未结 4 1445
野的像风
野的像风 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条回答
  •  萌比男神i
    2020-12-13 04:12

    I'm answering my own question.

    I tried adding following in my web.config

    
      
    
    

    Also decorated my Service with following attribute

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]    
    public class CalculatorService : ICalculatorSession    
    {
        // Implement calculator service methods
     }
    

    Still no use. Then I got the solution here by which you can use Elmah without HTTPContext. i.e. log errors by writing

    Elmah.ErrorLog.GetDefault(null).Log(new Error(ex));
    

    instead of

    Elmah.ErrorSignal.FromCurrentContext().Raise(error);
    

提交回复
热议问题