My application calls a web-service using WCF. The call can fail for various reasons:
- fault
- timeout
- connection lost
- ...
I want to log all such errors. Instead of wrapping every call in a try-catch, I want to do this in one place for all web-service calls in the entire application.
Unfortunately, an IClientMessageInspector does not get called for timeouts and connection failures. Is there a WCF extensibility point that I can use to centrally take note of all exceptions?
Notice, that I do not just want to log errors as text like WCF Tracing does it. I want to log:
- ServiceName
- MethodName
- Duration
- Exception.ToString()
I am open to workarounds.
I am not aware of an extensibility point, but I can provide a workaround that we have used. Basically, we created a "proxy" that all service calls were made through. Below is the proxy and an example of its use.
And an example of its use: