Search code examples
c#wcfsoaptrace

How to see SOAP Request and Response in WCF Tracing


I have enabled SwitchValue = All, and also Activity and Information.

Also enabled Messaging.

Still no luck, I couldn't get to see the soap request and response. Some instance I do see the exception or message.

I want to see "All inputs" values which is soap request. And also SOAP Response. What is that I am missing?


Solution

  • reference

    This is what I use in my web config:

    add this or a variation thereof to the system.servicemodel node:

    <diagnostics wmiProviderEnabled="true">
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="true"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="true"
           maxSizeOfMessageToLog="102400000"
           maxMessagesToLog="10000" />
    </diagnostics>
    

    Then add this node (you don't have to use the error logging part is not needed):

    <system.diagnostics>
        <trace autoflush="true" />
        <sources>
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLog"/>
                </listeners>
            </source>
            <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning">
                <listeners>
                    <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                        <filter type="" />
                    </add>
                    <add name="ServiceModelTraceListener">
                        <filter type="" />
                    </add>
                </listeners>
            </source>
            <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
                <listeners>
                    <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                        <filter type="" />
                    </add>
                    <add name="ServiceModelMessageLoggingListener">
                        <filter type="" />
                    </add>
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners>
            <add initializeData="C:\logs\TraceLogs\Web_tracelog_messages.svclog"
                type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
                <filter type="" />
            </add>
            <add initializeData="C:\logs\TraceLogs\Web_tracelog_errors.svclog"
              type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
              name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
                <filter type="" />
            </add>
            <add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="something.web"/>
        </sharedListeners>
    </system.diagnostics>