|
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
C# Trace.exe
[This sample can be found at M:\web\users\Sites\AspnetQuickStart\v2.0\QuickStart\howto\samples\Services\Tracing\Trace\
To build this sample, open the SDK command prompt and navigate to the above path. Build the sample using the build tool msbuild
passing the solution file as the first parameter: msbuild mySample.sln. The compiled executable will be found in the sub directory \bin
directory.]
Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.
|