home *** CD-ROM | disk | FTP | other *** search
Wrap
<!-- #include virtual="/quickstart/howto/include/header.inc" --> <h4>How Do I...Use tracing switches and listeners?</h4> <div class="indent" style="width:660"><font face="Tahoma" size="1"> <p>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, multi-tier 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.</p> <p>This sample illustrates the basics of using the Trace and Boolean switches. A switch provides an efficient mechanism for enabling/disabling code paths at runtime using external settings. 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 can then go to the registry and modify the settings of the switches and then run the sample again. You will possibly get a completely different output.</p> <p>Set DWORD value of the following key to 0 (false) or 1 (true):</p> </font><font face="Courier New" color="Blue" size="1"><blockquote> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\COMPlus\Switches\ABooleanSwitch </blockquote></font><font face="Tahoma" size="1"> <p>Set DWORD value of the following key to 0 (off), 1 (error), 2 (warning), 3 (info), or 4 (verbose):</p> </font><font face="Courier New" color="Blue" size="1"><blockquote> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\COMPlus\Switches\ATraceSwitch </blockquote></font><font face="Tahoma" size="1"> <p>For more information about switches and registry, please refer to the documentation for details on changing switch settings.</p> <p>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. </p> <p>Before running the application, open a command line window and run DbMon.exe. You will be able to see any Debug and Trace messages coming from any application running on your system.</p> <p> <b>Note: </b> The Debug Monitor utility (DBMon.exe) is available from the Windows Platform SDK on the <a target="_blank" href="http://msdn.microsoft.com">Microsoft Developer Network</a> website. </p> </font></div> <h4>Example</h4> <p> <div class="indent"> <a target="_blank" href="/quickstart/howto/samples/Services/Tracing/Switches/switches.exe"> <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br> </a> <div class="caption">Switches.exe</div><br> [<a target="_blank" href="/quickstart/howto/samples/Services/Tracing/Switches">View Sample</a>] | [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/Tracing/Switches/Switches.src">View Source</a>]<p> </div> <h4>Source Code</h4> <div class="code"> <xmp> <!-- #include virtual="/quickstart/howto/samples/Services/Tracing/Switches/Switches.cs" --> </xmp> </div> <!-- #include virtual="/quickstart/howto/include/footer.inc" -->