2

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://learn.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

venalyn sudaria
  • 149
  • 1
  • 11
  • 2
    It seems you're missing the `action` in your filter. The following format is default of `ContractNamespace/ContractName/OperationName` == `/soap:Envelope/soap:Header/YOURACTIONHERE` It looks like you have the namespace and contract name, but no operation name (action). The point of adding the `action` is to know what the filter should do, if not, what are you going to filter? Also, please have a [read](https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-3.5/aa967569(v=vs.90)?redirectedfrom=MSDN) at this article for more information. – Trevor Apr 16 '21 at 12:25
  • 1
    For information about "Configuring Tracing in WCF", you can refer to this link: https://stackoverflow.com/questions/4271517/how-to-turn-on-wcf-tracing – Ding Peng Apr 19 '21 at 08:38
  • @Codexer ``` /soap:Envelope/soap:Header/soap:Action[contains(text(),'readRequest')]``` I've edited my filter to this one. but still it says "The element cannot contains text. Content model is empty" Am I doing it wrong? – venalyn sudaria Apr 20 '21 at 09:11

0 Answers0