Because LeanSentry does not use intrusive monitoring, it relies on built-in ASP.NET exception logging to access error information. Unfortunately, WCF services hosted in IIS do not report unhandled exceptions the same way that ASP.NET applications do.
To enable error reporting for WCF applications
Do the following:
- Intercept the error in your service: http://msdn.microsoft.com/en-us/library/gg281715.aspx. You may already have this set up, or you can easily add it using the IErrorHandler pattern or the Faulted event on the ServiceHost class.
- Raise an error event via the ASP.NET health monitoring system.
This is how a normal ASP.NET application logs unhandled exceptions. (see https://leansentry.zendesk.com/entries/23584078-How-do-I-enable-ASP-NET-detailed-error-tracking- for more):
Create an error event wrapper:
public class MyRequestErrorWebEvent : WebRequestErrorEvent { public const int CustomEventCode = 100801; public MyRequestErrorWebEvent(string msg, Exception e) : base(msg, null, CustomEventCode, e) { } }
Then when you get an exception:// Raise the error to health monitoring new MyRequestErrorWebEvent("An unhandled request exception has occurred", exception).Raise();
If you have any issues with this approach, please email us!
Comments
0 comments
Article is closed for comments.