WCF Service Diagnosis Using Service Trace Viewer

One that I always have to look up here so am blogging it for reference!

I periodically develop WCF services and very occasionally during development, deployment and testing discover an unexpected ‘feature’! To diagnose what is going on it is useful to enable a service trace, by adding the following to your configuration file (web.config or app.config):

	<system.diagnostics>
		<sources>
			<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing" >
				<listeners>
					<add name="ServiceModelTraceListener"/>
				</listeners>
			</source>
			<source name="System.ServiceModel" switchValue="Warning,ActivityTracing"                >
				<listeners>
					<add name="ServiceModelTraceListener"/>
				</listeners>
			</source>
			<source name="System.Runtime.Serialization" switchValue="Warning,ActivityTracing">
				<listeners>
					<add name="ServiceModelTraceListener"/>
				</listeners>
			</source>
		</sources>
		<sharedListeners>
			<add initializeData="App_tracelog.svclog"
			   type="System.Diagnostics.XmlWriterTraceListener"
			   name="ServiceModelTraceListener" traceOutputOptions="Timestamp"/>
		</sharedListeners>
	</system.diagnostics>

The output of the trace is specified by the initializeData attribute. Specify it with a .svcLog extension (WCF Tracing File) so that the file can be opened and viewed in the Microsoft Service Trace Viewer Tool, which should be found in your WCF installation location (e.g. C:Program FilesMicrosoft SDKsWindowsv7.1binSvcTraceViewer.exe).

Full reference can be found on the MSDN site at: http://msdn.microsoft.com/en-us/library/ms732023.aspx

This entry was posted in .NET Development and tagged . Bookmark the permalink.

One Response to WCF Service Diagnosis Using Service Trace Viewer

  1. Pingback: WCF Debugging « Sladescross's Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>