Saturday 24 March 2012

How to get IntelliTrace in production for Web Applications with Visual Studio 11

Until yesterday, IntelliTrace in production environment was not supported, so the usefulness of it was a bit argued.

But now with Visual Studio 11, we can collect IntelliTrace logs from production environment in a completely supported way! And moreover, if you ask the Microsoft CSS (Customer Support Service) for help, the first question would be: “May you send me the IntelliTrace log please?”

Before of configuring IntelliTrace logs collection, we have to set security for the IIS Application pool account:

icacls sitepathIIS APPPOOL\<AppPool Account>”:(F)

image

Then, hands on the bits. Suppose we have a web application throwing an exception.

Firstly, we have to deploy IntelliTrace to the target environment. Pretty easy, just extract content from the IntelliTraceCollection.cab file you can find under the C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\11.0.0 path.

Then we have to extract it to the target server. I suggest using the expand command from a command prompt:

expand.exe /f:* IntelliTraceCollection.cab path

Lastly, bring up PowerShell:

image

We have to load the IntelliTrace PowerShell Module:

Import-Module sitepath\Microsoft.VisualStudio.IntelliTrace.PowerShell.dll

After doing so, we can get the full list of commands we can use:

Get-Command *IntelliTrace*

image

And now we collect logs about the target application:

Start-IntelliTraceCollection ApplicationPool CollectionPath OutputPath

CollectionPath is the path we chose for IntelliTrace. In there, there are two “profiles”: collection_plan.ASP.NET.default.xml which collects only IntelliTrace events, and collection_plan.ASP.NET.trace.xml, which traces also function calls and events.

OutputPath is where we store logs.

image

After deciding Yes (to all Smile) we have to run the application.

When we got the error, we have to snapshot the log file:

Checkpoint-IntelliTraceCollection ApplicationPool

image

And then we have to stop collecting it.

Stop-IntelliTraceCollection ApplicationPool

image

That’s all: we have the logs.

To analyse them, it’s just a classic IntelliTrace analysis as we always did.

2 comments:

  1. Is it possible to store _only_ unhandled exceptions? I think it would be extremely useful, or even have some mechanism to specify, from the app, when a session should be used.

    This way, it would replace a logging platform.

    Thanks!

    ReplyDelete
  2. With IntelliTrace you can get all it happens behind the exceptions. Then opening the .itrace file inside Visual Studio you can filter on whatever you need.
    IntelliTrace IMHO it doesn't replace a logging platform, because it's a manual process at the end. You can automatize it, but it would be a pain managing all the .itrace files, due to their size. The suggestion is: use a logging platform, and complete it with IntelliTrace when you have to fix a bug.

    ReplyDelete