Web API 2.1 (System.Web.Http v 5.1.0) allows catching and logging of Web API exceptions (see this answer : http://stackoverflow.com/a/21382651)
However, until then, I think I'll have to:
Use Try/Catch in my own API Controllers to log anything unhandled, and then re-throw
Rely on Umbraco logging deeper down in the stack, at a ContentService level, for instance, and hope those errors are logged. Also hope any Core controllers are kept slim, delegating their work to services, so there's less chance of unhandled exceptions occuring near the top.
Catching and logging UmbracoApi errors
Hi,
I have two levels of logging set up in my Umbraco 7.1.4 application:
Neither cases will trigger when there's an error generated in an UmbracoApi handler, such as
Forcing the application to error, by doing something silly such as:
works as expected.
Can anyone please help me understand what is going on?
Thanks,
Chris.
Hi Chris
Perhaps this post in last years version of the umbraco advent calendar can help? http://24days.in/umbraco/2013/log4net-in-umbraco/
/Jan
Cool! Will give it a read and let you know. Thanks.
Based on the article, I tried the custom Error.aspx Web.Config redirect - which doesn't kick in for UmbracoApi errors either.
I suspect that this is related to Web Api rather than anything to do with Umbraco - for instance I can see that Umbraco is rethrowing the exceptions correctly, I'm getting a 500 response back in my browser. See more here : http://stackoverflow.com/questions/16028919/catch-all-unhandled-exceptions-in-asp-net-web-api
I'm going to continue reading, will post any solutions I find here.
Thanks,
Chris.
Web API 2.1 (System.Web.Http v 5.1.0) allows catching and logging of Web API exceptions (see this answer : http://stackoverflow.com/a/21382651)
However, until then, I think I'll have to:
is working on a reply...