How to add filters in message logging wcf

Viewed 134

I have a WCF service and and was trying to log its request/response.

I was trying to add filters on message logging and tried to follow the instruction in here ... https://docs.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/configuring-message-logging

I was searching on the internet on how to do this, and here's what I've tried.

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

but when I hover the **<add>** it says The required attribute 'filter' is missing, and /soap:Envelope/soap:Header "The element cannot contain text.Content model is empty"

Am I doing it wrong?

Any ideas on how to do it? Thanks

0 Answers
Related