Q8M1 – SC Dudy Fathan Ali S.Kom
Distributed Application Development
Tracing and Monitoring WCF Services
Dudy Fathan Ali, S.Kom (DFA)2017
CEP - CCITFakultas Teknik Universitas Indonesia
Additional Documents
Q8M1 – SC Dudy Fathan Ali S.Kom
bit.ly/4sc1-repo
Download this Powerpoint Slide:
Objectives
Q8M1 – SC Dudy Fathan Ali S.Kom
Implementing Tracing
Configuring Tracing
Monitor a WCF Service
Q8M1 – SC Dudy Fathan Ali S.Kom
Implementing Tracing
Distributed Application Development
o Tracing:
o Is used to keep a track of the service execution.
o Helps you to enhance the performance of a WCF service by analyzing its behavior and identifying errors.
o Enables you to view diagnostic information about the service.
o Can be used to display custom tracing information, such as customized messages about the execution of the service.
Q8M1 – SC Dudy Fathan Ali S.Kom
Implementing Tracing
Distributed Application Development
o WCF enables you to analyze and examine a WCF service by implementing tracing.
o WCF allows you to compare and correlate the errors and processes of WCF services by implementing end-to-end (e2e) tracing.
o End-to-End tracing enables you to trace the execution of the code of a WCF service to provide detailed tracing information.
o WCF provides the following mechanisms called correlation mechanisms to diagnose the cause of the error:
o Activity
o Transfer
o Propagation
Q8M1 – SC Dudy Fathan Ali S.Kom
Implementing Tracing
Distributed Application Development
o Activity:
o An activity is a processing unit that helps you to reduce the scope of error generation.
o The errors that occur in the same activity are directly related to each other.
o To trace the errors that occur in an activity, you need to write the following code snippet:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="
Information, ActivityTracing" >
</source>
</sources>
</system.diagnostics>
Q8M1 – SC Dudy Fathan Ali S.Kom
Implementing Tracing
Distributed Application Development
o Transfer:
o Between activities represent causal relationship between events in the related activities.
o Between activities happens when the control flows from one activity to another.
Q8M1 – SC Dudy Fathan Ali S.Kom
Implementing Tracing
Distributed Application Development
o Propagation:
o Propagation enables you to group the tracing information of errors that occurred in the same activity across endpoints.
o This enables you to compare and correlate the grouped tracing information and find the cause of the errors.
o To implement propagation in a WCF service, you need to write the following code snippet:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="
Information, ActivityTracing“ propagateActivity="true">
</source>
</sources>
</system.diagnostics>
Q8M1 – SC Dudy Fathan Ali S.Kom
Implementing Tracing
Distributed Application Development
o Steps to create WCF Diagnostic Implementation
1. Create a new WCF Service Application
2. Edit the Web.Config and add the configuration code
3. Run the service
4. Open the service log file using WCF Service Trace Viewer
Q8M1 – SC Dudy Fathan Ali S.Kom
Configuring Tracing
Distributed Application Development
o To create and configure a trace listener, you can write the following code snippet in the web.config file of a WCF service:
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= “path\to\directory" />
</sharedListeners>
</system.diagnostics>
Q8M1 – SC Dudy Fathan Ali S.Kom
Configuring Tracing
Distributed Application Development
o Add this following code in System.ServiceModel section:
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="3000"
/>
</diagnostics>
Q8M1 – SC Dudy Fathan Ali S.Kom
Monitor a WCF Service
Distributed Application Development
o Launch the WCF Service Trace Viewer (svctraceviewer.exe) and open the log file from the location and path specified in your web.config.
Q8M1 – SC Dudy Fathan Ali S.Kom
Thank You!Dudy Fathan Ali, S.Kom
Top Related