Logging exceptions in WCF with IErrorHandler inside HandleError or ProvideFault?

Posted by Dannerbo on Stack Overflow See other posts from Stack Overflow or by Dannerbo
Published on 2010-05-19T21:08:15Z Indexed on 2010/05/19 21:10 UTC
Read the original article Hit count: 658

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about wcf

Related posts about exception