Friday, October 29, 2010

Tracing a Web Reference

  1. First you will need SvcTraceViewer.exe which should be some where similar to;
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe
  2. Add your Web Reference to the project and code as normal
  3. To trace the service you will need to modify your app.Config file
The essential parts required to get a trace that can be viewed with SvcTraceViewer are;
  • <diagnostics> section which should be added after the <system.servicemodel> tag and before the <bindings> tag

<diagnostics>messagelogging logentiremessage="true"
logmalformedmessages="true" logmessagesatservicelevel="true"
logmessagesattransportlevel="true" maxmessagestolog="100"
maxsizeofmessagetolog="10000000"</diagnostics>

  • After the </system.serviceModel> tag you should then add the following <system.Diagnostics> section

<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information,ActivityTracing" propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="All" propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="c:\abc.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="xml" />
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>

  • Run your application and then locate your c:\abc.svclog file
  • Note that you should name and locate the initializeData attribute in a sensible location and a meaning full name.

No comments:

Post a Comment