Custom error trace listener: Create the installer class

After you create the trace listener constructor class, you implement the installer class.

The installer class executes logic on the application start. To create the installer class:

  1. In Visual Studio, open the context menu of the ExternalLogging project and click Add » Class
  2. Name the class file Installer.cs and click Add.
  3. Open the Installer.cs file and add method PreApplicationStart.
    In the code of the method, you subscribe to the Log.Configuring event which is raised before the start of the Sitefinity CMS logging configuration.
  4. Add the Configuring event handler.
    In this code section, you resolve the default configurator. Next, you create an instance of the RaygunConfigurator that that you previously created. Finally, you register the RaygunConfigurator instance using ObjectFactory.Container.RegisterInstance<ISitefinityLogCategoryConfigurator>(customConfigurator);

    GITHUB EXAMPLE: For more information about the content of the file, see the Installer.cs file of the downloaded sample project.

  5. Add the AssemblyInfo.cs class, which must be located in the Properties folder of the ExternalLogging project.
    In the code of the class, the PreApplicationStart method in the Installer class is called by ASP.NET on application start of any Sitefinity CMS project. 

    GITHUB EXAMPLE: For more information about the content of the file, see the AssemblyInfo.cs file of the downloaded sample project.

Finally, you need to reference the ExternalLogging class library, in your Sitefinity CMS application.

Was this article helpful?