Our shop has a TraceListener that send events to a repository via a webservice call. We use it for our own TraceSources, but want to be able to use it for other TraceSources, like System.ServiceModel and System.Activities.
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing" propagateActivity="true">
<listeners>
<add name="TheSharedListenerInQuestion" />
</listeners>
</source>
The problem is we use a WCF client call to do the Write within the TraceListener and if the System.ServiceModel tracesource is attached to my listener I end up in a loop, eg trace an event which fires the internal client call, which in turn makes the WCF tracesource fire a TraceEvent and the loop ensues.
How do I make my internal WCF call not cause the WCF tracesources to fire?
I don't think that is logically possible. To use code-under-trace in the trace listener will necessarily create an infinite loop, however, that said:
One crazy idea would be to write a custom TraceFilter that inspects the stack trace to see if the tracelistener is the origin of the call or if it is some other client. There may be another more clever solution, I would have to set a break point inside a custom trace Filter and look to see if anything about the context is distinguishable (maybe by filtering on the endpoint name)