将Elmah与ServiceStack.Mvc一起使用 [英] Using Elmah with ServiceStack.Mvc
问题描述
在/elmah.axd路径上看不到未处理的异常(MyService:RestServiceBase)。
I could not see unhandled exceptions ( MyService:RestServiceBase) on /elmah.axd path.
我添加了http处理程序以查看错误。
I've added http handlers for seeing errors.
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
我已经安装了ServiceStack.Logging.Elmah
I've installed ServiceStack.Logging.Elmah
更新
我还安装了Elmah.Mvc软件包
I've installed Elmah.Mvc package also
我可以在Controller的操作中得到错误,但不能得到服务错误!
I can get errors in Controller's Action but I could not get service errors!
UPDATE
我并不孤单:)
https:// groups .google.com / forum /#!topic / servicestack / WSrM5CLL120
推荐答案
您需要订阅<$ c通常在AppHost类中的 Configure
方法中的$ c> AppHostBase.ServiceExceptionHandler 事件:
You need subscribe to AppHostBase.ServiceExceptionHandler
events in Configure
method which normally resides in AppHost class:
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);
};
}
....
}
这篇关于将Elmah与ServiceStack.Mvc一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!