How can we enable tracing on the readymade tracing WCF objects?

 Posted by articlesMaint on 9/15/2009 | Category: WCF Interview questions | Views: 3021

We will enable tracing on ‘System.ServiceModel’ tracing object. To enable tracing we need to enable the ‘system.diagnostics’ XML node in the ‘web.config’ file of the WCF service. We need to also define the type of listeners for the ‘System.ServiceModel’ listener object. So we add the ‘listeners’ tag with the type as ‘System.Diagnostics.XmlWriterTraceListener’. We need to also define the file and path where the file is created. For the current scenario we have defined the file as ‘Traces.svclog’ and the folder as ‘c:\’ drive.


<source name="System.ServiceModel"
switchValue="Information, ActivityTracing">
<add name="log"
initializeData="c:\Traces.svclog" />

Now if you run the WCF service you can see a XML file created as shown below.

#<E2ETraceEvent xmlns="">

<System xmlns="">
<SubType Name="Transfer">0</SubType>
<TimeCreated SystemTime="2009-04-30T03:21:09.5625000Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" RelatedActivityID="{d11829b7-d2db-46d5-a4ac-49a37a56376e}" />
<Execution ProcessName="WebDev.WebServer" ProcessID="2660" ThreadID="8" />

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response