Managed Tracing in the .NET Framework 

In earlier versions of ADO, the lack of a standard OLE DB trace made it difficult to resolve problems in OLE DB and ADO. This has been remedied in ADO.NET 2.0. ADO.NET 2.0 introduces new built-in data tracing functionality that is supported by the .NET data providers for SQL Server, Oracle, OLE DB and ODBC, as well as the ADO.NET DataSet, and the SQL Server 2005 network.

Tracing database API calls can help diagnose the following problems:

  • Schema mismatch between client program and the database.

  • Database unavailability or network library problems.

  • Incorrect SQL whether hard coded or generated by an application.

  • Incorrect programming logic.

  • Issues resulting from the interaction between multiple ADO.NET components or between ADO.NET and your own components--for example, tracking how the data-binding infrastructure is using ADO.NET objects.

To support different trace technologies, tracing is extensible, so a developer can trace a problem at any level of the application stack. Although tracing is not an ADO.NET-only feature, Microsoft providers in ADO.NET 2.0 take advantage of generalized tracing and instrumentation APIs.

Event Tracing for Windows

ADO.NET 2.0 comes with an adapter to the Event Tracing for Windows (ETW) system. ETW is a high-performance tracing system, provides low-overhead tracing, and is fast enough to allow tracing in real time.

ADO.NET can register the following ETW event providers:

  • System.Data.1 -- ADO.NET providers and classes in System.Data.dll.

  • System.Data.OracleClient - OracleClient provider in System.OracleClient.dll.

  • System.Data.SNI.1 -- SNI from System.Data.

  • ADONETDIAG.ETW -- Events from the ETW adapter itself.

ETW provider logs time stamp each event. When you start the trace, you can specify a high-resolution time stamp or a low-resolution time stamp. ETW traces can be used with an ASP.NET trace or a low-level operating-system kernel trace. All of the events can be logged on a per-provider basis to a single file or to separate files.

Setting Up Tracing

The basic steps for using tracing are as follows:

  1. Set up the data tracing DLL registry entry, ETW providers, and Windows Management Instrumentation (WMI) schemas.

  2. Configure and run the trace.

  3. Harvest the trace results as a comma-separated value file.

For complete information on setting and configuring managed tracing in ADO.NET 2.0, see Tracing Data Access: A Gentle Introduction to ADO.NET 2.0 Trace FacilitiesTracing Data Access: A Gentle Introduction to ADO.NET 2.0 Trace Facilities, on MSDN.

See Also