Debugging SharePoint in Production Environment

I don't remember the number of times I have heard this phrase and at one point in time I have said it myself: "this is not reproducible on my machine or it works in UAT but not in production". Now without installing Visual Studio we can collect diagnostics data from the production environment. In Visual Studio 2012 Update 1 there is an application,, in ..\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\11.0.0


To debug apps in production or other environments running in IIS 7.0 and 7.5 we can use the IntelliTrace collector to save diagnostic data to an IntelliTrace log file; a .iTrace file. This lets us record what happened in our app without installing Visual Studio or changing our app's environment. When we're done collecting data, just delete the collector to uninstall it.

Installing the collector

  1. Copy the cab file in a directory for ex: E:\Intellitrace
  2. Expand using e:\Intellitrace>expand /f:* e:\intellitrace where "f" is the switch, the" ." after the cab file is to maintain the folder structure and the destination folder needs to be specified.

Collecting data from SharePoint Application

To start collecting data, use this syntax:

Start-IntelliTraceCollection <ApplicationPool> <PathToCollectionPlan> <FullPathToITraceFileDirectory>

To stop collecting data, use this syntax:

Stop-IntelliTraceCollection <ApplicationPool>

For example, to collect data from a SharePoint application in the SharePoint - 80 application pool:

Start-IntelliTraceCollection "SharePoint - 80" "e:\IntelliTraceCollector\collection_plan.ASP.NET.default.xml" "e:\IntelliTraceLogs"

Open the .iTrace file in Visual Studio Ultimate. We can start debugging from Visual Studio itself if the symbol file (.pdb files) are available.


The path to a collection plan is an .xml file that configures settings for the collector. We can specify a plan that comes with the collector. The following plans work for Web apps and SharePoint applications:

Plan Name Description
collection_plan.ASP.NET.default.xml Collects only IntelliTrace events and SharePoint events, including exceptions, database calls, and Web server requests.
collection_plan.ASP.NET.trace.xml Collects function calls and all the data in collection_plan.ASP.NET.default.xml. This plan is good for detailed analysis, but it might slow down your app more than collection_plan.ASP.NET.default.xml.

If we look at the debug options in Visual Studio and choose IntelliTrace we see (as in the following) each option matches one mentioned above.


Modifying the Collection Plan

Just as we are likely to make modifications to the IntelliTrace settings in Visual Studio we may want to modify the collection settings when using the files from the cab. The easiest way of doing this is by looking at the options in Visual Studio and then making the equivalent change in the collection plan XML file that we wish to use with our application.


Points to be noted

  • Trace File Size: By default, the max size of the .iTrace file is 100 MB. When the .iTrace file reaches this limit, the collector deletes the file's earliest entries (wraps around) to make space for newer entries. To change this limit, edit the collection plan's MaximumLogFileSize attribute.
  • PDB Files: Make sure to save the symbol (.pdb) files. To debug with IntelliTrace and step through code, one must have the matching source files and symbol files.
  • Security: Restrict the .iTrace file directory only to those identities that must work with the collector. An .iTrace file might contain sensitive information, such as data from users, databases, other source locations, and connection strings because IntelliTrace can record any data that passes into method parameters. If other people must have access, copy the files to a secure shared location.
  • Permissions: For a Web app or SharePoint application, provide its application pool full permissions to the .iTrace file directory.
  • Performance: We can reduce startup time by disabling events that aren't relevant to the app. For example, disable Windows Workflow events for apps that don't use Windows Workflow. We can improve both startup and runtime performance by disabling registry events for apps that access the registry but don't show problems with registry settings. Review the modules in the collection plan for which IntelliTrace collects data. We can specify the modules to be excluded such that the scope of gathering diagnostics data is limited to the problematic areas.

Up Next
    Ebook Download
    View all
    View all