2012-08-22 78 views
3

我在/elmah.axd路徑上看不到未處理的異常(MyService:RestServiceBase)。使用Elmah和ServiceStack.Mvc

我已經添加了http處理程序來查看錯誤。

<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> 

我已經安裝了ServiceStack.Logging.Elmah

UPDATE

我已經安裝了Elmah.Mvc包還

我可以得到錯誤的控制器的行動,但我能沒有得到服務錯誤!

UPDATE

我並不孤獨:) https://groups.google.com/forum/#!topic/servicestack/WSrM5CLL120

回答

4

您需要訂閱AppHostBase.ServiceExceptionHandler事件中,通常位於APPHOST類Configure方法:

public class AppHost : AppHostBase 
{ 
    .... 

    public override void Configure(Funq.Container container) 
    { 
     ServiceExceptionHandler += (request, exception) => 
     { 
      //pass the exception over to Elmah 
      var context = HttpContext.Current; 
      Elmah.ErrorLog.GetDefault(context).Log(new Error(exception, context)); 

      //call default exception handler or prepare your own custom response 
      return DtoUtils.HandleException(this, request, exception); 
     }; 
    } 

    .... 
}