DOCUMENTATION

ASP.NET Core Web

See the basic setup steps below to get started with the Logify Alert service:


The following additional step may be required, based on your application deployment strategy:

Generate an API Key

The Logify Alert service uses unique identifiers – API keys – to register and monitor individual applications. You will use this key later when creating an instance of Logify Alert client in code.

  1. Log in to the Logify Alert website: logify.devexpress.com.

  2. Switch to the Applications tab and click Create New Application.

  3. Specify the application name and description, then click Create.

  4. The Applications tab will now display a new entry with an auto-generated API key.

Send Reports to Logify Alert

This section explains how to modify your ASP.NET Core web application so that it reports unhandled exceptions to the Logify Alert service.

Add the Logify Alert Client to Your Project

Select Tools | NuGet Package Manager | Package Manager Console in Visual Studio's main menu and execute the following command:

Install-Package Logify.Alert.Web

Enable Automatic Reporting

Follow the steps below to automatically intercept all unhandled exceptions and send the corresponding crash reports to Logify Alert.

  1. Specify an API Key to register your application in the Logify Alert service. To do this, add the LogifyAlert section to the root level of your application's appsettings.json file:

    {   "LogifyAlert": {     "apiKey": "SPECIFY_YOUR_API_KEY_HERE"   } }

    You can also load Logify Alert configuration settings from your own config file in JSON, XML or INI format.

    1. Add the Logify Alert configuration settings to your JSON file (for example, LogifyAlert.json):

      {   "LogifyAlert": {     "apiKey": "SPECIFY_YOUR_API_KEY_HERE"   } }

    2. Add the following code to the BuildWebHost method declared in the application's Program.cs file to load the Logify Alert settings form the specified configuration file:

      public static IWebHost BuildWebHost(string[] args) =>   WebHost.CreateDefaultBuilder(args)     .ConfigureAppConfiguration((context, builder) => {       builder.AddJsonFile("LogifyAlert.json", optional: false, reloadOnChange: false);     }) .UseStartup<Startup>() .Build();

    1. Install the Microsoft.Extensions.Configuration.Xml NuGet package.

    2. Add the Logify Alert configuration settings to your XML file (for example, LogifyAlert.xml):

      <configuration>   <LogifyAlert>     <ApiKey>SPECIFY_YOUR_API_KEY_HERE</ApiKey>     <AppName>YOUR_APPLICATION_NAME</AppName>     <AppVersion>1.0.2</AppVersion>   </LogifyAlert> </configuration>

    3. Add the following code to the BuildWebHost method declared in the application's Program.cs file to load the Logify Alert settings from the specified file:

      public static IWebHost BuildWebHost(string[] args) =>   WebHost.CreateDefaultBuilder(args)     .ConfigureAppConfiguration((context, builder) => {       builder.AddXmlFile("LogifyAlert.xml", optional: false, reloadOnChange: false);     }) .UseStartup<Startup>() .Build();

    1. Install the Microsoft.Extensions.Configuration.Ini NuGet package.

    2. Add the Logify Alert configuration settings to your INI file (for example, LogifyAlert.ini):

      [LogifyAlert] ApiKey = SPECIFY_YOUR_API_KEY_HERE AppName = Your application name ApiVersion = 1.0.2

    3. Add the following code to the BuildWebHost method declared in the application's Program.cs file to load the Logify Alert settings from the specified file:

      public static IWebHost BuildWebHost(string[] args) =>   WebHost.CreateDefaultBuilder(args)     .ConfigureAppConfiguration((context, builder) => {       builder.AddIniFile("LogifyAlert.ini", optional: false, reloadOnChange: false);     }) .UseStartup<Startup>() .Build();


  2. In the application's Startup.cs file, add the LogifyAlert initialization in the Configure method after the app.UseExceptionHandler or app.UseDeveloperExceptionPage method call depending on your project type, and before the app.UseMvc method call, if any.

    using DevExpress.Logify.Web; // ... public void Configure(IApplicationBuilder app, IHostingEnvironment env) {   if (env.IsDevelopment())   {     app.UseDeveloperExceptionPage();   }   else   {     app.UseExceptionHandler("/Home/Error");   }   app.UseLogifyAlert(Configuration.GetSection("LogifyAlert"));   // ... }

    using DevExpress.Logify.Web; // ... public void Configure(IApplicationBuilder app, IHostingEnvironment env) {   if (env.IsDevelopment())   {     app.UseDeveloperExceptionPage();   }   app.UseLogifyAlert(Configuration.GetSection("LogifyAlert"));   // ... }

Manual Reporting

Use the following code to catch exceptions and send reports manually:

using DevExpress.Logify.Web; // ... try {   LogifyAlert.Instance.ApiKey = "SPECIFY_YOUR_API_KEY_HERE";   RunYourCode(); } catch (Exception e) {   LogifyAlert.Instance.Send(e); }

Rebuild and Run Your Application

Once your updated application has been redeployed, log in to logify.devexpress.com to review and process incoming reports.

Manual Application Deployment

Skip this step if you are using Visual Studio’s integrated application deployment mechanism. Since you have added Logify Alert client to the project using NuGet, all necessary DLLs will automatically be deployed.

If you are not using Visual Studio’s deployment mechanism, make sure to add the following assemblies to your project’s distribution:

  • Logify.Alert.Core.dll
  • Logify.Alert.Web.dll

Terms of use Copyright © 2016-2019 Developer Express Inc.