You can locally monitor IIS-hosted ASP.NET web apps and SharePoint 2010 or 2013 applications for errors, performance issues, or other problems by using Microsoft Monitoring Agent. You can save diagnostic events from the agent to an IntelliTrace log (.iTrace) file. You can then open the log in Visual Studio Ultimate 2013 to debug problems with all the Visual Studio diagnostic tools.
If you use System Center 2012, use Microsoft Monitoring Agent with Operations Manager to get alerts about problems and create Team Foundation Server work items with links to the saved IntelliTrace logs. You can then assign these work items to others for further debugging.
Before you start, check that you have the matching source and symbols for the built and deployed code. This helps you go directly to the application code when you start debugging and browsing diagnostic events in the IntelliTrace log. Set up your builds so that Visual Studio can automatically find and open the matching source for your deployed code.
Set up the standalone agent
- Make sure that:
- Your web server is running supported versions of Internet Information Services (IIS).
- Your web server has .NET Framework 3.5, 4, or 4.5.
- Your web server is running Windows PowerShell 3.0 or later. What if I have Windows PowerShell 2.0?
- You have administrator permissions on your web server to run PowerShell commands and to recycle the application pool when you start monitoring.
- You’ve uninstalled any earlier versions of Microsoft Monitoring Agent.
- Download the free Microsoft Monitoring Agent, either the 32-bit version MMASetup-i386.exe or 64-bit version MMASetup-AMD64.exe, from the Microsoft Download Center to your web server.
- Run the downloaded executable to start the installation wizard.
- Create a secure directory on your web server to store the IntelliTrace logs, for example, C:\IntelliTraceLogs.
Make sure that you create this directory before you start monitoring. To avoid slowing down your app, choose a location on a local high-speed disk that’s not very active.
Security Note IntelliTrace logs might contain personal and sensitive data. Restrict this directory to only those identities that must work with the files. Check your company’s privacy policies.
- To run detailed, function-level monitoring or to monitor SharePoint applications, give the application pool that hosts your web app or SharePoint application read and write permissions to the IntelliTrace log directory. How do I set up permissions for the application pool?
- On your web server, open a Windows PowerShell or Windows PowerShell ISE command prompt window as an administrator.
- Run the Start-WebApplicationMonitoring command to start monitoring your app. This will restart all the web apps on your web server.
Here’s the short syntax:
Start-WebApplicationMonitoring “<appName>” <monitoringMode> “<outputPath>” <UInt32> “<collectionPlanPathAndFileName>”
Here’s an example that uses just the web app name and lightweight Monitor mode:
PS C:\>Start-WebApplicationMonitoring “Fabrikam\FabrikamFiber.Web” Monitor “C:\IntelliTraceLogs”
Here’s an example that uses the IIS path and lightweight Monitor mode:
PS C:\>Start-WebApplicationMonitoring “IIS:\sites\Fabrikam\FabrikamFiber.Web” Monitor “C:\IntelliTraceLogs”
After you start monitoring, you might see the Microsoft Monitoring Agent pause while your apps restart.
“<appName>” Specify the path to the web site and web app name in IIS. You can also include the IIS path, if you prefer.
You can find this path in IIS Manager. For example:
<monitoringMode> Specify the monitoring mode:
- Monitor: Record minimal details about exception events and performance events. This mode uses the default collection plan.
- Trace: Record function-level details or monitor SharePoint 2010 and SharePoint 2013 applications by using the specified collection plan. This mode might make your app run more slowly.
- Make sure that the application pool has read and write permissions to the IntelliTrace log directory.
- How can I get the most data without slowing down my app?
This example records events for a SharePoint app hosted on a SharePoint site:
Start-WebApplicationMonitoring “FabrikamSharePointSite\FabrikamSharePointApp” Trace “C:\Program Files\Microsoft Monitoring Agent\Agent\IntelliTraceCollector\collection_plan.ASP.NET.default.xml” “C:\IntelliTraceLogs”
- Custom: Record custom details by using specified custom collection plan. You’ll have to restart monitoring if you edit the collection plan after monitoring has already started.
“<outputPath>” Specify the full directory path to store the IntelliTrace logs. Make sure that you create this directory before you start monitoring. <UInt32> Specify the maximum size for the IntelliTrace log. The default maximum size of the IntelliTrace log is 250 MB.
When the log reaches this limit, the agent overwrites the earliest entries to make space for more entries. To change this limit, use the -MaximumFileSizeInMegabytes option or edit the MaximumLogFileSize attribute in the collection plan.
“<collectionPlanPathAndFileName>” Specify the full path or relative path and the file name of the collection plan. This plan is an .xml file that configures settings for the agent.
These plans are included with the agent and work with web apps and SharePoint applications:
Collects only events, such as exceptions, performance events, database calls, and Web server requests.
Collects function-level calls plus all the data in default collection plan. This plan is good for detailed analysis but might slow down your app.
You can find localized versions of these plans in the agent’s subfolders. You can also customize these plans or create your own plans to avoid slowing down your app. Put any custom plans in the same secure location as the agent.
For the more information about the full syntax and other examples, run the get-help Start-WebApplicationMonitoring –detailed command or the get-help Start-WebApplicationMonitoring –examples command.
- To check the status of all monitored web apps, run the Get-WebApplicationMonitoringStatus command.