How Do I... Work with tracing?

Trace instrumentation allows developers and administrators to monitor the health of applications running in real-life settings (as opposed to running in a debugger). Sometimes using a debugger can hide bugs and obscure some performance and threading problems. Tracing is a very important monitoring and debugging tool for distributed, multitier applications. Such applications often contain problems that can only be observed when the application is under a heavy load and the inherent randomness of a real-life environment.

This sample illustrates the basics of using the Trace and Debug classes. Run it and take a look at the source code. You will see how easy it is to add simple tracing to your applications.

You have to compile your instrumented applications with trace or debug compiler directives enabled. Otherwise, all calls to Trace or Debug (respectively) are ignored during compilation.

Before running the application, open a command line window and run the Debug Monitor utility (DbMon.exe). You will be able to see any debug and trace messages coming from any application running on your system.

Note: DBMon.exe is available from the Windows Platform SDK on the Microsoft Developer Network website.

Example

 
VB Trace.exe

[Run Sample] | [View Source]


Copyright 2001 Microsoft Corporation. All rights reserved.