<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Error, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\logs\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
Hi, I use this config section to trace just the errors from the WCF service, but when I open my svclog file I can see all the activity on the service. How can I log only the errors in my svclog file.
Remove "ActivtiyTracing" from the switchValue Attribute
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Error"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\logs\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
You can control Tracing by settings the Switch attribute :
<configuration>
<system.diagnostics>
<switches>
<add name="mySwitch" value="4" />
</switches>
</system.diagnostics>
The corresponding values are this :
Trace Level
Off : 0
Error : 1
Warning : 2
Info : 3
Verbose : 4
On MSDN you will find more explanation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.