I have a WCF service with an implementation of IErrorHandler. In its HandleError method I am logging the exception using a TraceSource:
public bool HandleError(Exception error)
{
tracer.TraceEvent(TraceEventType.Error, 0, error.ToString());
return true;
}
However, when this method is entered the Trace.CorrelationManager.ActivityId has changed from what I set it to at the start of the service method. So I get a log entry with some random activity ID, which kind of ruins the activity trace.
Is WCF doing this? and why?
I think you need to do some extra work due to WCF.
See if this link helps:
Extending / Custom FaultContractExceptionHandler for Exception Handling in WCF