Sync Service for ADO. NET program debugging (i)

Source: Internet
Author: User
Tags switches

Use tracing to generate log (data synchronization log) [desktop]

The sync Service for Ado.net is an important part of Microsoft's MSF (Microsoft Sync Framework), which provides a complete development framework for synchronizing offline data with various scenarios. We can use it to develop some complex scenarios to adapt to complex enterprise logic. For example, in a distributed scenario: we create a server and then use the Sync Service for ado.net to synchronize data using dozens of or thousands of PCs, notebook, and WM Device (mobile PDA mobile devices) as client segments.

For this complex distributed synchronization scenario, how to debug and correct it? Tracing in Sync Services is required at this time.

What is tracing in Sync Services?

Tracing records the various operations of the program, including synchronizing data and metadata, and then gives the information to Listener. As a Listener, this information can be recorded in a file as log logs, or other places that are transmitted according to your request. In a distributed program, tracing is very important because you need to use it to debug bugs in the program to find the root cause of the problem. Otherwise, it is very difficult to find the root cause of the problem.

How to start opening tracing in Sync Services

By default, tracing is turned off. We can turn on tracing by configuring Trace Listener.

We can edit the app.config to open the tracing, please add the following code:

<configuration>
 <system.diagnostics>
  <switches>
   <!-- 0-off, 1-error, 2-warn, 3-info, 4-verbose. -->
   <add name="SyncTracer" value="3" />
  </switches>

  <trace autoflush="true">
   <listeners>
    <add name="TestListener" type="System.Diagnostics.TextWriterTraceListener"  initializeData="c:\TraceSample.txt"/>
   </listeners>
  </trace>
 </system.diagnostics>
</configuration>

How to select the appropriate trace level

Trace records have some performance implications, and you need to seriously consider how to set up TraceLevel to balance trace records against product performance.

Typically, if you just want to monitor the error message, choose Tracelevel=1 or 2. When you need more log information to facilitate debugging observation, you can tracelevel=3 or 4, remember that this time the log generated is very detailed, and its corresponding log file will be very large-this will give the performance of the program has no small impact. In general, we will only use this tracelevel in debugging errors and in the development process.

For more information, see the following table:

switch value tr Acing level output
0 off no messages to trace listener S.
error only error messages to trace listeners.
warning error and warning messages to trace listeners.
info informational, warning, and error messages to trace listeners.
4 verbose all messages to trace listeners.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.