DOCUMENTATION
Console
See the basic setup steps below to get started with the Logify Alert service:
The following additional steps may be required, based on your application deployment strategy and logging service preferences:
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.
-
Log in to the Logify Alert website: logify.devexpress.com.
-
Switch to the Applications tab and click Create New Application.
-
Specify the application name and description, then click Create.
-
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 console 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.Console
Enable Automatic Reporting
Set up the Logify Alert client and call its StartExceptionsHandling method at the beginning of the Main method in the Program.cs file to automatically intercept all unhandled exceptions and send the corresponding crash reports to Logify Alert.
using DevExpress.Logify.Console;
// ...
LogifyAlert client = LogifyAlert.Instance;
client.ApiKey = "SPECIFY_YOUR_API_KEY_HERE";
client.StartExceptionsHandling();
You can also set up the Logify Alert client in a configuration file:
Specify Logify Alert's configuration settings in your project's App.config file which is automatically changed when you install a NuGet package containing a Logify Alert client.
<configuration>
<configSections>
<section name="logifyAlert" type="DevExpress.Logify.LogifyConfigSection, Logify.Alert.Console"/>
</configSections>
...
<logifyAlert>
<apiKey value="SPECIFY_YOUR_API_KEY_HERE"/>
</logifyAlert>
</configuration>
-
Create a new JSON file in your project (for example, appsettings.json).
-
Add Logify Alert's configuration settings to this file:
{ "LogifyAlert": { "apiKey": "SPECIFY_YOUR_API_KEY_HERE" } }
-
Set the configuration file's Copy to Output Directory property to Copy Always.
-
Install the following NuGet packages:
- Microsoft.Extensions.Configuration
- Microsoft.Extensions.Configuration.FileExtensions
- Microsoft.Extensions.Configuration.Json
-
Add the following code at the beginning of the Main method in the Program.cs file:
using System.IO; using Microsoft.Extensions.Configuration; using DevExpress.Logify.Console; // ... var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: false); IConfigurationRoot configuration = builder.Build(); LogifyAlert client = LogifyAlert.Instance; client.Configure(configuration.GetSection("LogifyAlert"));
Manual Reporting
Use the following code to catch exceptions and send reports manually:
using DevExpress.Logify.Console;
// ...
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.Console.dll
Integration with Logging Tools (.NET Console Apps)
Logify can automatically record crash reports in your project’s centralized log when using the following logging services:
|
|