【问题标题】:Ignore certain WCF services from WCF trace logs从 WCF 跟踪日志中忽略某些 WCF 服务
【发布时间】:2012-04-30 14:47:36
【问题描述】:

我正在构建的应用程序公开了几个 WCF 服务(A、B)。在内部,它使用在我们的内部网络(X,Y)上运行的其他几个 WCF 服务。

使用 WCF 消息记录,我希望记录我们的服务 A、B 与调用它们的外部客户端之间的流量。

WCF 不应记录我的服务 (A,B) 和后端服务 (X,Y) 之间的任何数据。

通过 system.serviceModel/diagnostics/messageLogging/filters 过滤部分成功:

    <filters>
      <add nodeQuota="10" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        /s:Envelope/s:Header/*[contains(text(),"MyServiceA")]
      </add>
      <add nodeQuota="10" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">
        /s:Envelope/s:Header/a:Action[contains(text(),"MyServiceA")]
      </add>
    </filters>

然而,这无法捕获来自我们服务的响应,因为 SOAP responses 不包含要过滤的文本。

WCF MessageLogTraceRecord 确实包含 SOAP 操作,但我似乎无法构造过滤器来访问它:

<MessageLogTraceRecord>
  <Addressing xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace>
     <Action>http://opia.api.translink.com.au/ApiLocationService/2012/04/IApiLocationService/ResolveInputServiceFaultFault</Action>
  </Addressing>
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Body>
        ...

在所有选项设置为 true 的情况下启用 WCF 消息记录和端到端跟踪。 ActivityTracing 和警告级别日志记录已启用。

【问题讨论】:

  • 您想过滤是因为您担心文件大小或噪音? MS Service Trace Viewer UI 非常擅长过滤。
  • 主要是噪音。 “内部”服务非常健谈,对我们服务的一次调用包含对他们的 30 多个调用。然而,内部服务接口已经过良好测试,无法对其进行任何更改。

标签: wcf wcf-client


【解决方案1】:

试试这个

<filters>
      <add nodeQuota="10" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        /s:Envelope/s:Header/*[contains(text(),"MyServiceA")]
      </add>
      <add nodeQuota="10" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">
        /s:Envelope/s:Header/a:Action[contains(text(),"http://opia.api.translink.com.au/ApiLocationService/2012/04/IApiLocationService/ResolveInputServiceFaultFault")]
      </add>
    </filters> 

将操作过滤器中的文本“MyServiceA”替换为 MessageLogTraceRecord > 操作中的 URL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-02
    • 1970-01-01
    • 2011-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多