Troubleshooting Application Errors in Production

If you don't have the right logging or tools in place, troubleshooting issues that are occurring in a Live environment can often feel like finding a needle in a haystack. We've put together this guide to help Developers debug and get back on track as soon as possible.

Setup/Review Application Insights (if possible)

If your website is hosted in Azure, you can use a service called Application Insights to track all sorts of telemetry from your website. Once installed in your MVC application, you'll be able view your exceptions, dependencies, page speed, user flows, and much more within the Azure portal.

We always recommend getting this in place first, as this will help narrow your focus. If your site is hosted with Agility in Azure, please contact for access.

Check the Web Log

The first thing you should do if you are getting any sort of error on the site is check your Web Logs in Agility.


You can access the Web Logs for any of your syncing servers by going to Settings > Customization/Development/ > Web Logs

Web Logs will show you all the exceptions and and other info that your application has logged. The Web Logs are only as good as how you use them though. If you feel you aren't seeing the error that's occurring please double-check you are writing to the Agility log. You may also want to add additional logging for further review. You learn more about setting up Web Logging here.

Custom Errors Getting in the Way?

While we never recommend deploying a Production agility website with CustomError off, sometimes your custom error page may have an exception in itself and you the original exception gets lost in translation. To get around this, you can temporarily disable CustomErrors in the web.config to assist with troubleshooting. User beware, don't forget to turn them back on!

Does it Work in Preview Mode?

There can be cases where the application is hitting an exception trying to find published Agility Content. While the code should always handle those cases, its possible there's a bug. The quickest way to determine if it's an issue around content not being published is to Preview the production server. You can do this by Previewing the appropriate page from Agility. 

Debug it Locally in Development Mode

Regardless of whether you found a log indicating the error, it's probably a good idea to run your project locally to try and reproduce. This is usually the fastest way to reproduce, fix and deploy. To debug locally, you'll need to have access to the source code and ensure you run the site with the following web.config setting set with developmentMode="true":

  <!--Agility  settings-->
    <settings applicationName="Agility Sample MVC4" developmentMode="true" contentCacheFilePath="c:\AgilityContent\">

Debug it Locally in Live Mode

If you aren't able to reproduce the issue locally, you may need to run the application in Live Mode with a copy of the Live Content files. The reason for this is that your Local/Staging content files include all the latest content from Agility regardless of whether they've been published or not. While the Live content files only include content that has been published.

To do this you need to retrieve the Live Content files from the production web server. If your site is hosted by Agility then you can contact and we can retrieve and send those files to you.

If you host the site yourself, you can get those off the Web Server by navigating to your contentCacheFilePath as defined in your web.config and grab the folder called "Live" under your website name. An example path could be c:\AgilityContent\{websiteName}\Live.

Next, you'll need copy those Live Content files to your local developer machine into the appropriate contentCacheFilePath as defined in your local web.config. If you've ran the site localy before you should notice there will already be a folder like c:\AgilityContent\{websiteName}\Staging that contains the content files downloaded while in developmentMode. You'll just need to add the Live folder to the same directory.

Next, you'll need to update your local web.config to set developmentMode="false":

  <!--Agility  settings-->
    <settings applicationName="Agility Sample MVC4" developmentMode="false" contentCacheFilePath="c:\AgilityContent\">

Now, run the project using IIS Express or local IIS and you should now be using the exact same Live content that your production web server was using. You've now got an exact replica of your production environment should help you nail down any discrepancies in content. Often, there can be a case where the application expects a specific content item or page to be published and it doesn't degrade gracefully when it can't find that item. 

2 out of 2 found this helpful



Please sign in to leave a comment.