Enable C++ project system logging

Update (7 June 2012): Instructions when using Visual Studio 2012

The new Visual C++ project system in Visual Studio 2010 leverages the .NET System.Diagnostics trace logging feature to help users investigate why certain operations have failed or just to better understand what is happening behind the scenes. 

Here are some features that VC++ logs lots of messages about so you can diagnose any bad behavior:

  1. Design-time build failures, such as project, COM, or assembly references that won’t resolve
  2. Project filters
  3. IDE build up-to-date check

In order to avoid negatively impacting performance in the common case where you don’t care to review the trace logs, we only emit the trace messages when a user “opts in” to logging these messages.  To enable logging in the Visual C++ project system you just have to add a snippet to a .config file:

  1. Since it can be difficult to recover from a damaged devenv.exe.config file, consider copying the file to devenv.exe.config.original before modifying it so you have a backup copy you can revert to if things go awry.

  2. Open a text editor with admin privileges.

  3. Open your %PROGRAMFILES%\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config file.  Note this will be in %ProgramFiles(x86)% on 64-bit Windows.

  4. Add this snippet to your devenv.exe.config file just below the <configSections /> block:

        <add name="CPS" value="4" />
  5. Save the text file.

You can find out more about setting traceswitch verbosity levels on MSDN.  Why the name “CPS” for our trace switch?  Just an implementation detail for this release.

Now that we’ve enabled logging of VC++ messages, we need a way to view them.  You have a few options here.  You can pick any ONE of the following:

  1. Configure the System.Diagnostics trace to be logged to a text file.
  2. DebugView is a free Sysinternals tool that displays all log messages on screen and doesn’t require any installation.
  3. Attach a debugger to the devenv.exe process (perhaps another instance of devenv.exe) and watch the Debug pane of the Output window (Debug –> Windows –> Output).

Regardless of how you view the resulting log messages, you may find that they are quite verbose.  Many services in Visual Studio 2010 log messages and many of these are “on by default” (VC++ logging is off by default, which is why we modified the .config file).  Try a keyword search to scan for the messages that you’re interested in and then scan through the surrounding messages to find the ones that can help identify whatever you’re investigating.

Here’s a sample picture of DebugView showing the relevant log message explaining why a special project type doesn’t get standard up-to-date check behavior in the IDE: