使用ELMAH与ServiceStack.Mvc(Using Elmah with ServiceS

2019-07-31 03:39发布

我看不出异常(产生的MyService:RestServiceBase)/elmah.axd路径上。

我已经添加了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

Answer 1:

您需要订阅AppHostBase.ServiceExceptionHandler在事件Configure通常驻留在APPHOST类方法:

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

    ....
}


文章来源: Using Elmah with ServiceStack.Mvc