首页 > 解决方案 > WCF 跟踪添加过滤器

问题描述

我想在我的 WCF 跟踪中添加一个过滤器,以过滤端点或消息的内容。

从我所看到的如何做到这一点尚不清楚。我正在尝试在 web.config 文件中执行此操作。

欢迎任何想法。

谢谢伊恩

标签: wcftrace

解决方案


请尝试以下配置,跟踪 WCF 活动。

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel" propagateActivity="true" switchValue="Information, ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.XmlWriterTraceListener" name="xmlLog" initializeData="myLogs.svclog"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false"/>
    </diagnostics>
  </system.serviceModel>

您可以参考以下链接自定义配置。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/samples/tracing-and-message-logging
https://docs.microsoft.com/en-us/dotnet/framework/wcf/diagnostics /tracing/configuring-tracing
获得跟踪文件后,我们可以使用它Microsoft Service Trace Viewer来过滤 WCF 活动。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/service-trace-viewer-tool-svctraceviewer-exe
https://docs.microsoft.com/en-us/dotnet/framework/wcf /diagnostics/tracing/using-service-trace-viewer-for-viewing-correlated-traces-and-troubleshooting
如果有什么我可以帮忙的,请随时告诉我。


推荐阅读