Interview Preparation mode beta
Funny Facebook Status Funny Facebook Status
Enter your email address

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

Nice?Vote!
asked 1 year ago in .NET Interview Questions and Answers by KrishnaMachiraju (7,980 points)

1 Answer

Nice?Vote!
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.
<system.diagnostics>

<sources>

<source name="System.ServiceModel"

switchValue="Information, ActivityTracing">

<listeners>

<add name="log"

type="System.Diagnostics.XmlWriterTraceListener"

initializeData="c:\Traces.svclog" />

</listeners>

</source>

</sources>

</system.diagnostics>


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

#<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">

<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">

<EventID>0</EventID>

<Type>3</Type>

<SubType Name="Transfer">0</SubType>

<Level>255</Level>

<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" />

<Channel/>

<Computer>COMPAQ-JZP37MD0</Computer>

</System>

<ApplicationData></ApplicationData>

</E2ETraceEvent>
answered 1 year ago by KrishnaMachiraju (7,980 points)

Related questions