WCF 的日志配置

对于一些疑难杂症,我们无法根据经验去判断的时候,只能用日志来表述一切

 

下面看看对WCF 的日志配置

在Configuration中插入以下节点

 

  1. <system.diagnostics>  
  2.         <sources>  
  3.             <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">  
  4.                 <listeners>  
  5.                     <add type="System.Diagnostics.DefaultTraceListener" name="Default">  
  6.                         <filter type="" />  
  7.                     </add>  
  8.                     <add name="ServiceModelMessageLoggingListener">  
  9.                         <filter type="" />  
  10.                     </add>  
  11.                 </listeners>  
  12.             </source>  
  13.             <source name="System.ServiceModel" switchValue="Warning, ActivityTracing"  
  14.               propagateActivity="true">  
  15.                 <listeners>  
  16.                     <add type="System.Diagnostics.DefaultTraceListener" name="Default">  
  17.                         <filter type="" />  
  18.                     </add>  
  19.                     <add name="ServiceModelTraceListener">  
  20.                         <filter type="" />  
  21.                     </add>  
  22.                 </listeners>  
  23.             </source>  
  24.         </sources>  
  25.         <sharedListeners>  
  26.             <add initializeData="app_messages.svclog"  
  27.               type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"  
  28.               name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">  
  29.                 <filter type="" />  
  30.             </add>  
  31.             <add initializeData="app_tracelog.svclog"  
  32.               type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"  
  33.               name="ServiceModelTraceListener" traceOutputOptions="Timestamp">  
  34.                 <filter type="" />  
  35.             </add>  
  36.         </sharedListeners>  
  37.         <trace autoflush="true" />  
  38.     </system.diagnostics>  
 

 

在System.serviceModel 中插入以下节点

 

  1. <diagnostics wmiProviderEnabled="true" performanceCounters="All">  
  2.   <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />  
  3.  </diagnostics>  
 

 

ok , 当然还可以用配置管理器来配置  WCF 的日志记录。

posted @ 2014-03-22 23:17  王永华  阅读(714)  评论(0编辑  收藏  举报