Automatic registration of unhandled exceptions without using try / catch

So I want to be able to just log all unhandled exceptions to the event log without manually picking up all exceptions and logging them.

I wanted to use the health monitoring functionality in the WCF service, the problem is that this only catches errors generated by asp.net and I specifically want to also catch SPException errors thrown by the call in SharePoint.

It seems that exceptions are only handled if they call the raise method on the WebBaseErrorEvent in the System.Management namespace, I suppose ASP.Net exceptions do this in essence, but SPExceptions do not. So my only option is for errors when I manually run SPException and write them to the event log, or create a new WebBaseErrorEvent object and call a raise on it that wins, which is what I want to achieve.

I am missing something, is there an easier way?

+2


source to share


1 answer


Looked at ELMAH

I know yours are a little deeper in the stack, but can't they get through?



TBH, what's more, since the SPException is outside of my ken, but will leave notepad. To think that someone has a blog called sharepoint an exception!

And credit to @Alex for pointing this question in the comments.

+2


source







All Articles