服务器端跟踪WCF服务的SOAP消息

时间:2010-02-25 19:07:59

标签: wcf soap trace

我正在尝试关注this tutorial为我的WCF服务配置服务器端SOAP跟踪,以及MSDN documentation

当我运行测试时,我在Microsoft Service Trace Viewer中看到Activity 00000000,但是messages选项卡为空。正在编写C:\ temp \ Web_tracelog.svclog,但C:\ temp \ Web_messages.svclog不是。

我可能在这里遗漏了一些简单的东西,但不能把手指放在它上面。

Microsoft服务配置编辑器的“诊断”选项卡显示所有内容都已启用。 web.config的相关部分如下。

<system.diagnostics>
  <sources>
   <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing"
    propagateActivity="true">
    <listeners>
     <add type="System.Diagnostics.DefaultTraceListener" name="Default">
      <filter type="" />
     </add>
     <add name="ServiceModelTraceListener">
      <filter type="" />
     </add>
    </listeners>
   </source>
   <source name="System.ServiceModel.MessageLogging" switchValue="Verbose, ActivityTracing">
    <listeners>
     <add type="System.Diagnostics.DefaultTraceListener" name="Default">
      <filter type="" />
     </add>
     <add name="ServiceModelMessageLoggingListener">
      <filter type="" />
     </add>
    </listeners>
   </source>
  </sources>
  <sharedListeners>
   <add initializeData="C:\temp\Web_tracelog.svclog"
    type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
    <filter type="" />
   </add>
   <add initializeData="C:\temp\Web_messages.svclog"
    type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
    <filter type="" />
   </add>
  </sharedListeners>
  <trace autoflush="true" />
</system.diagnostics>

 <system.serviceModel>
  <diagnostics>
   <messageLogging logEntireMessage="true" logMalformedMessages="true"
    logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
  </diagnostics>
 </system.serviceModel>

1 个答案:

答案 0 :(得分:4)

无法看到该配置有什么问题,但是我使用的配置在没有任何问题的情况下可以正常工作:

<system.diagnostics>
  <sources>
    <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
      <listeners>
        <add name="ServiceModelTraceListener"
         initializeData="c:\MyTracelog.svclog"
         type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
         traceOutputOptions="Timestamp"/>
      </listeners>
    </source>
  </sources>
  <trace autoflush="true" />
</system.diagnostics>

<system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true"
              logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
</system.serviceModel>