忽略特定的WCF服务在WCF跟踪日志中的记录

6

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

通过使用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 响应 不包含可过滤的文本。

WCF MessageLogTraceRecord 包含 SOAP Action,但我似乎无法构造筛选器来访问它:

<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>
        ...

启用了WCF消息记录和端到端跟踪,所有选项均设置为true。启用了ActivityTracing和Warning级别日志记录。


1
你是否想要进行筛选,因为你关注文件大小或噪音?MS Service Trace Viewer UI 在筛选方面非常出色。 - Petar Vučetin
1
主要是噪音。 "内部"服务非常喜欢聊天,我们的一个服务调用会包装30多个对他们的调用。但是内部服务接口经过了充分测试,不能对其进行任何更改。 - geoffreys
1个回答

2

试试这个

<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 > Action中的URL


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接