Plugin for NLog
Logify Alert provides you with a plugin that allows integrating Logify reports with NLog logs.
Install the Plugin
To add the plugin to the application's code, follow the steps below.
-
Select Tools | NuGet Package Manager | Package Manager Console from the Visual Studio main menu.
-
Execute the command below.
Install-Package Logify.Alert.NLog
-
Execute the command below.
WinForms applications: Install-Package Logify.Alert.Win
Web applications: Install-Package Logify.Alert.Web
WPF applications: Install-Package Logify.Alert.Wpf
Console applications: Install-Package Logify.Alert.Console
Set Up the Plugin
Set up the plugin according to your target platform. The App.config example below demonstrates how to set up the plugin for a WinForms application.
<configuration>
<configSections>
<section name="logifyAlert" type="DevExpress.Logify.LogifyConfigSection, Logify.Alert.Win" />
</configSections>
<logifyAlert>
<apiKey value="SPECIFY_YOUR_API_KEY_HERE" />
<confirmSend value="false" />
<customData>
<add key="MACHINE_NAME" value="My Server" />
</customData>
</logifyAlert>
</configuration>
Register a Target
Register the LogifyAlert target as a custom NLog target in the NLog.config configuration file as follows.
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="Logify.Alert.NLog" />
</extensions>
<targets>
<target name="logifyAlert" xsi:type="LogifyAlert" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="logifyAlert" />
</rules>
</nlog>
Initialize the Client
Add the following code to your application's code. The example below demonstrates how to set up the plugin for a WinForms application.
using DevExpress.Logify.Win;
LogifyAlert client = LogifyAlert.Instance;
Now, each time your application sends an Error message with non-empty LogEvent.Exception parameter to the NLog system, a new report is generated and sent to Logify Alert. For example:
logger.Error(new Exception("Test Logify exception"), "Test message");