对于一些疑难杂症,我们无法根据经验去判断的时候,只能用日志来表述一切
下面看看对WCF 的日志配置
在Configuration中插入以下节点
-
<system.diagnostics>
-
<sources>
-
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
-
<listeners>
-
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
-
<filter type="" />
-
</add>
-
<add name="ServiceModelMessageLoggingListener">
-
<filter type="" />
-
</add>
-
</listeners>
-
</source>
-
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
-
propagateActivity="true">
-
<listeners>
-
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
-
<filter type="" />
-
</add>
-
<add name="ServiceModelTraceListener">
-
<filter type="" />
-
</add>
-
</listeners>
-
</source>
-
</sources>
-
<sharedListeners>
-
<add initializeData="app_messages.svclog"
-
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
-
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
-
<filter type="" />
-
</add>
-
<add initializeData="app_tracelog.svclog"
-
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
-
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
-
<filter type="" />
-
</add>
-
</sharedListeners>
-
<trace autoflush="true" />
-
</system.diagnostics>
在System.serviceModel 中插入以下节点
-
<diagnostics wmiProviderEnabled="true" performanceCounters="All">
-
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
-
</diagnostics>
ok , 当然还可以用配置管理器来配置 WCF 的日志记录。