Logging exceptions in WCF with IErrorHandler inside HandleError or ProvideFault?
- by Dannerbo
I'm using IErrorHandler to do exception handling in WCF and now I want to log the exceptions, along with the stack trace and the user that caused the exception. I've read everywhere to put the logging in the HandleError method, and not the ProvideFault method. My question is, why?
The only way I can see to get the user that caused the exception is:
OperationContext.Current.IncomingMessageProperties.Security.ServiceSecurityContext.PrimaryIdentity
...But this only seems to work inside ProvideFault, and not inside HandleError. Is there a way to get the user inside HandleError?