Mapping the Web analytics storage folder to the server file system

If your project uses an Azure Blob Storage file system (Azure projects deployed to Cloud Services by default or other projects with the <add key=“CMSExternalStorageName” value=“azure” /> web.config key), the system stores web analytics logs on the blob storage. The web analytics functionality writes and processes logs every minute, which can cause latency problems when using blob storage. Additionally, web analytics may create a large number of files, which further degrades the performance of the blob storage.

We highly recommend that you map the folder storing web analytics data to the local file system of the server:

  1. Open your project in Visual Studio.

  2. Create a new class in the App_Code folder or CMSApp_AppCode -> Old_App_Code on web application projects.

  3. Use the following code to map the Web analytics storage to the local file system (in ~/App_Data/CMSModules/WebAnalytics). See Configuring file system providers for more information.

     using CMS.IO;
     using CMS.Base;
     public partial class CMSModuleLoader
         private class CustomStorageAttribute : CMSLoaderAttribute
             /// <summary>        
             /// The system executes the Init method of the CMSModuleLoader attributes when the application starts.
             /// </summary>
             public override void Init()
                 // Creates a new StorageProvider instance with the default Windows file system provider
                 AbstractStorageProvider webAnalyticsProvider = new StorageProvider();
                 // Maps the web analytics directory to the provider
                 StorageHelper.MapStoragePath("~/App_Data/CMSModules/WebAnalytics", webAnalyticsProvider);
  4. Save the file. If your project is installed in the web application format, rebuild the solution.

  5. If your project is deployed to Azure, re-deploy your project.

The system now stores web analytics log on the server’s file system instead of the blob storage.