Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to log incoming and outgoing XML from WCF requests

Tags:

logging

wcf

I have a basic WCF hosted in a console app, and a basic console WCF client. How do you look at the requests sent between the two apps (over localhost)?

Should I use something like 'Wireshark' or would it be possible to log out the incoming and outgoing response objects in visual Studio?

I'm already creating an log.svclog file by the system.diagnostics directive in the App.config file, but can't find the actual request and response xml:

<diagnostics>
  <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>

<system.diagnostics>
  <sources>
    <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
      <listeners>
        <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\log\log.svclog" />
      </listeners>
    </source>
  </sources>
</system.diagnostics>

Which I got from Stack Overflow (I can't remember where)

like image 226
Zach Smith Avatar asked Mar 30 '17 20:03

Zach Smith


1 Answers

You need to configure message logging, which is separate from just WCF tracing, which is what you have configured above. See https://msdn.microsoft.com/en-us/library/ms730064(v=vs.110).aspx.

like image 136
tomasr Avatar answered Nov 21 '22 00:11

tomasr