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 Note |
---|
This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties. |
To get samples and instructions for installing them:
To access samples from Visual Studio
On the Help menu, click Samples.
By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.
- For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.
Building and Running the Sample
To build and run this sample
Open the solution file tracetool.sln.
From the Build menu, click Build.
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
Debug an MFC or ATL project by clicking Start from the Debug menu.
From the Tools menu, click MFC/ATL Trace Tool if it is not already running.
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.
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.
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.