<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>嗨,我使用这个配置节来跟踪来自WCF服务的错误,但是当我打开我的svclog文件时,我可以看到该服务上的所有活动。如何在我的svclog文件中只记录错误。
发布于 2013-09-16 17:30:25
从switchValue属性中删除"ActivtiyTracing“
<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>发布于 2013-09-16 17:34:23
您可以通过设置Switch属性来控制跟踪:
<configuration>
<system.diagnostics>
<switches>
<add name="mySwitch" value="4" />
</switches>
</system.diagnostics>
相应的值如下:
Trace Level
Off : 0
Error : 1
Warning : 2
Info : 3
Verbose : 4在MSDN上你会找到更多的解释
TraceLevel Enumeration
https://stackoverflow.com/questions/18824578
复制相似问题