问题
I could not see unhandled exceptions ( MyService:RestServiceBase) on /elmah.axd path.
I've added http handlers for seeing errors.
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
I've installed ServiceStack.Logging.Elmah
UPDATE
I've installed Elmah.Mvc package also
I can get errors in Controller's Action but I could not get service errors!
UPDATE
I'm not alone :) https://groups.google.com/forum/#!topic/servicestack/WSrM5CLL120
回答1:
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);
};
}
....
}
来源:https://stackoverflow.com/questions/12080911/using-elmah-with-servicestack-mvc