2

I currently have WCF Tracing set in my app.config like so :

<system.diagnostics>
<trace autoflush="true">
  <listeners>
  </listeners>
</trace>
<sources>
  <source name="System.ServiceModel" switchValue="Information, ActivityTracing">
    <listeners>
      <add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="WcfDetailTrace.svclog" />
    </listeners>
  </source>
</sources>

This works as expected, however, I want to be able to programmatically set the file location and filename of my log file to something other than WcfDetailTrace.svclog.

Currently I have tried adding this to my Service Host:

TraceSource ts = new TraceSource("System.ServiceModel");                
var listener = new XmlWriterTraceListener(SomeCustomFilename + ".svclog", "std2");           
ts.Listeners.Add(listener);

The above only seems to log data into my custom file when I use the method ts.TraceData()

Is there someway to make all the WCF logging, that currently goes into file WcfDetailTrace.svclog to go into my custom file instead?

caa
  • 406
  • 1
  • 8
  • 16

0 Answers0