ATLTraceTool Sample: Displays Output of ATLTRACE2

The ATLTraceTool sample builds an application that specifies which ATLTRACE2 messages appear in the output window. This application, the ATL Trace Tool, displays debug trace messages in the ATL and MFC sources. You can control the type and amount of messages displayed.

AtlTraceTool.exe ships in Visual Studio and can be found in the \Program Files\Microsoft Visual Studio 9.0\Common7\Tools directory. AtlTraceTool.exe is also available from the Tools menu in the development environment.

Security noteSecurity Note:

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To get samples and instructions for installing them:

  • On the Visual Studio Help menu, click Samples.

    For more information, see Visual Studio Samples.

  • The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.

Building and Running the Sample

To build and run this sample

  1. Open the solution file tracetool.sln.

  2. From the Build menu, click Build.

  3. From the Debug menu, click Start Without Debugging.

Note

This procedure is optional. You can use the prebuilt AtlTraceTool.exe instead if you want.

To use ATLTraceTool.exe

  1. Debug an MFC or ATL project by clicking Start from the Debug menu.

  2. From the Tools menu, click MFC/ATL Trace Tool if it is not already running.

  3. Expand the tree control list in the Trace List window. The window shows the running application, any modules within that application, and the trace categories for each module.

  4. Customize, for each process, module, and category, which information is displayed in the output window. The Trace level control in the Process group is related to the ATLTRACE2 level; only those ATLTRACE2 messages with a level equal to or greater than the setting in the Trace level control will be displayed in the output window.

  5. Click Apply to put your settings into effect.

You can save your settings and load them the next time you debug the application; use the Save and Load buttons.

ATL Trace Tool User Interface

  • Trace List
    A tree control with a list of processes that use debug ATL/MFC sources. Under each process, modules are listed and under each module, trace categories are listed.

  • Refresh
    Updates the list of processes and modules under Trace List.

  • Process Group
    Process-wide settings:

    Trace level – Equates to the trace level parameter in calls to ATLTRACE2. Currently the ATL/MFC sources use a trace level of 0–4, where 0 is the most critical level.

    Enabled – Enables tracing for the process.

    Category & Function Names – Includes the trace category and function name in trace messages.

    File Name & Line No. – Includes the file name and line number in trace messages.

  • Module Group
    You must first select a module in the Trace List tree control before this group is enabled. These settings affect the module.

    Trace level – Equates to the trace level parameter in calls to ATLTRACE2. Currently the ATL/MFC sources use a trace level of 0–4, where 0 is the most critical.

    Inherit from Process – Allows trace settings in the Process group to also be used for this module.

    Enabled – Enables tracing for this module.

    Disabled – Disables tracing for this module.

  • Category Group
    You must first select a category in the Trace List tree control before this group is enabled. These settings affect the category within the module.

    Trace level – Equates to the trace level parameter in calls to ATLTRACE2. Currently the ATL/MFC sources use a trace level of 0–4, where 0 is the most critical.

    Inherit from Module – Allows trace settings in the Module group to also be used for this category.

    Enabled – Enables tracing for this category.

    Disabled – Disables tracing for this category.

  • Save
    Saves settings for the current process and all modules under it to a .trc file. The .trc file can be loaded by using the Load button or by calling AtlTraceLoadSettings from the project. If the .trc file is located in the same directory as the EXE/DLL, you can call AtlTraceLoadSettings and pass a NULL for the file name.

  • Load
    Loads a .trc file.

  • Apply
    Applies the current settings to the loaded process.

  • Close
    Closes the ATL/MFC Trace Tool dialog box. Changes will not take effect unless Apply was selected.

  • Help
    Displays help.

See Also

Other Resources

ATL Samples