November 24, 2014
Hot Topics:

ADO.NET Trace Logging

  • January 22, 2008
  • By Bipin Joshi
  • Send Email »
  • More Articles »

Introduction

Tracing allows you to keep track of various events happening in the system. Tracing allows you to track the sequence of code execution along with the time taken for each step. Together, tracing can throw light on how your code is being executed and the performance of every step. Many real world applications are database driven and call for performance optimization of your data access code. Luckily, ADO.NET 2.0 provides built-in support for trace logging. The ADO.NET trace logging is tuned for performance and uses Event Tracing for Windows (ETW) providers. This article explains how you can configure the ADO.NET trace logging feature.

Enabling ADO.NET Trace Logging

The ADO.NET trace logging is not enabled by default. To enable it, you need to follow these steps:

  • Add certain Registry entries
  • Configure ETW providers for ADO.NET
  • Create a trace log using the Logman command line tool
  • Start the tracing

Now, see each step in more detail.

Add Required Registry Entries

The trace logging feature of ADO.NET is dependent on a DLL named AdoNetDiag.dll. This DLL is located in the installation folder of .NET. The following figure shows this DLL in Windows Explorer.



Click here for a larger image.

The AdoNetDiag.dll is a component that makes any class library designed for trace logging appear as an ETW provider. In the example, it will make assemblies such as System.Data.dll appear as ETW providers.

Now, open the Windows Registry editor (regedit.exe) and locate the following key:

HKLM\Software\Microsoft\BidInterface

By default, the BidInterface key will not have any sub-key. Add a sub-key to BidInterface named Loader. Then, add a string value under Loader with a name such as :Path and a value as the full path and name of AdoNetDiag.dll assembly (see below).



Click here for a larger image.

Configure ETW Providers for ADO.NET

Now, you need to configure AdoNetDiag.dll so that it is visible on a public ETW provider list as well as the WMI (Windows Management Instrumentation) provider list. This can be done with the help of the mofcomp.exe command line tool. The mofcomp.exe tool expects a .mof (Managed Object Format) file containing details about the objects to be added to the WMI repository. For AdoNetDiag.dll, the required .mof file is available in the same folder as the AdoNetDiag.dll itself (see below).



Click here for a larger image.

Open Command Prompt and issue the following command:

mofcomp.exe C:\Windows\Microsoft.Net\Framework\v2.0.50727\
   AdoNetDiag.mof




Page 1 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel