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, IntelliTraceCollection.cab, in ..\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\11.0.0

Debugging-SharePoint-in-Production-Environment.jpg

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:* IntelliTraceCollection.cab. 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.

PathToCollectionPlan

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.

PathToCollectionPlan.jpg

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.

Modifying-the-Collection-Plan.jpg

Points to be noted