微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在消息记录 wcf 中添加过滤器

如何解决如何在消息记录 wcf 中添加过滤器

我有一个 WCF 服务,并且正在尝试记录它的请求/响应。

我试图在消息记录中添加过滤器并尝试按照此处的说明进行操作...https://docs.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/configuring-message-logging

我在互联网上搜索了如何做到这一点,这是我尝试过的。

<system.serviceModel>
   <diagnostics>
          <!-- log all messages sent/received at the service model level -->
          <messageLogging logEntireMessage="true"
                          maxMessagesToLog="1000"
                          maxSizeOfMessagetoLog="69905067"
                          logMessagesAtServiceLevel="true",logMessagesAtTransportLevel="true">
            <filters>
              <add nodeQuota="10" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                       /soap:Envelope/soap:Header
              </add>
            </filters>
          
          </messageLogging>
         
        </diagnostics>
</system.serviceModel>


<system.diagnostics>
    <sources>
      
      <!-- Log all messages in the 'Messages' tab of SvcTraceViewer. -->
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xml"
           type="System.Diagnostics.XmlWriterTraceListener"
           initializeData="C:\LOGFILE.svclog"
           traceOutputoptions="LogicalOperationStack,DateTime,Timestamp,ProcessId,ThreadId,Callstack"/>
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>
<filters>
              <add xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                       /soap:Envelope/soap:Header
              </add>
</filters>

但是当我将鼠标悬停在 **<add>** 上时,它说 缺少必需的属性“过滤器”,并且 /soap:Envelope/soap:Header “元素不能包含文本。内容模型为空"

我做错了吗?

关于如何做到这一点的任何想法? 谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。