views:

239

answers:

1

So I want to be able to just log all unhandled exceptions to the event log without having to catch all the exceptions manually and write them out.

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

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

Am I missing something is there an easier way?

+2  A: 

Looked at ELMAH

I know yours are a little more deep down the stack but would these not come through?

TBH, any more with regard SPException is beyond my ken, but will leave blog of note. To think someone has a blog called sharepoint exception!

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

dove
This question should help a lot: http://stackoverflow.com/questions/829796/using-elmah-in-a-sharepoint-environment
Alex Angas