DOCUMENTATION

WinForms, Web and WPF Clients

To add the Logify Alert client to the application's code, follow the steps below.

  1. Select Tools | NuGet Package Manager | Package Manager Console from the Visual Studio main menu.

  2. Execute the command below.

    WinForms and Console applications: Install-Package Logify.Alert.Win

    Web applications: Install-Package Logify.Alert.Web

    WPF applications: Install-Package Logify.Alert.Wpf

The clients are represented by the LogifyAlert class that consists of the following properties, methods, events and attributes.

Properties

ApiKey

Type: String

Specifies an API Key used to register the applications within the Logify Alert service.

client.ApiKey = "SPECIFY_YOUR_API_KEY_HERE";

AllowRemoteConfiguration

Type: Boolean
Default value: false

Specifies whether a Logify Alert client configuration can be specified remotely.

client.AllowRemoteConfiguration = true;

AppName

Type: String
Default value: null

Specifies an application name.

client.AppName = "My Application";

AppVersion

Type: String
Default value: null

Specifies an application version.

client.AppVersion = "1.0.2";

Attachments

Type: AttachmentCollection

Specifies a collection of files attached to a report. The total attachments size must not be more than 3 Mb per one crash report. The attachment name must be unique within one crash report.

using DevExpress.Logify.Core;
using DevExpress.Logify.Win;

LogifyAlert client = LogifyAlert.Instance;
client.ApiKey = "SPECIFY_YOUR_API_KEY_HERE";

Attachment newAt = new Attachment();
newAt.Name = "MyAttachedImage.jpg";
newAt.Content = File.ReadAllBytes(@"C:\Work\Image_to_attach.jpg");
// We strongly recommend that you specify the attachment type.
newAt.MimeType = "image/jpeg";

client.Attachments.Add(newAt);
client.StartExceptionsHandling();

CollectBreadcrumbs

Type: Boolean
Default value: false

Specifies whether automatic breadcrumbs collecting is enabled.

The total breadcrumbs size is limited by 1000 instances (or 3 Mb) per one crash report by default. To change the maximum allowed size of attached breadcrumbs, use the BreadcrumbsMaxCount property.

LogifyAlert.Instance.CollectBreadcrumbs = true;  
LogifyAlert.Instance.StartExceptionsHandling();

CollectMiniDump
(WinForms and WPF clients only)

Type: Boolean
Default value: false

Specifies whether automatic minidumps collecting is enabled.

LogifyAlert.Instance.CollectMiniDump = true;

ConfirmSendReport
(WinForms and WPF clients only)

Type: Boolean
Default value: false

Specifies whether or not a user must confirm sending reports to the Logify Alert service. By default, all uncaught exceptions are automatically processed and sent to the Logify Alert service.

client.ConfirmSendReport = true;

To customize the confirmation dialog appearance, handle the ConfirmationDialogShowing event.

CustomData

Type: IDictionary<String, String>

Gets the collection of custom data sent with generated reports.

Use the CustomData property to attach additional information to the generated report. For instance, you can use this property to track additional metrics that are important in terms of your application: CPU usage, environment parameters, and so on.

The field name can only consists of a-z, A-Z, 0-9, and _ characters.

client.CustomData["CustomerName"] = "Mary";

IgnoreCookies
(ASP.NET and ASP.NET Core clients only)

Type: String
Default value: null

Specifies cookies that should be excluded from a crash report.

Provide a comma-separated list of names to ignore several cookies. Set this property to the asterisk (*) character to remove all cookies from a Logify Alert report. Also, use the asterisk (*) character as a wildcard to substitute any character(s) when specifying a cookie to be ignored. This property is case-insensitive.

LogifyAlert.Instance.IgnoreCookies = "*";

IgnoreFormFields
(ASP.NET and ASP.NET Core clients only)

Type: String
Default value: null

Specifies form fields that should be excluded from a crash report.

Provide a comma-separated list of names to ignore several form fields. Set this property to the asterisk (*) character to remove all form data from a Logify Alert report. Also, use the asterisk (*) character as a wildcard to substitute any character(s) when specifying a form field to be ignored. For example, when you set IgnoreFormFields ="*Password*", Logify Alert will ignore all form fields containing the “password” in the name. This property is case-insensitive.

LogifyAlert.Instance.IgnoreFormFields = "creditcard,password";

IgnoreHeaders
(ASP.NET and ASP.NET Core clients only)

Type: String
Default value: null

Specifies request headers that should be excluded from a crash report.

Provide a comma-separated list of names to ignore several headers. Set this property to the asterisk (*) character to remove all headers from a Logify Alert report. Also, use the asterisk (*) character as a wildcard to substitute any character(s) when specifying a header to be ignored. This property is case-insensitive.

LogifyAlert.Instance.IgnoreHeaders = "*";

IgnoreServerVariables
(ASP.NET clients only)

Type: String
Default value: null

Specifies server variables that should be excluded from a crash report.

Provide a comma-separated list of names to ignore several server variables. Set this property to the asterisk (*) character to remove all server variables from a Logify Alert report. Also, use the asterisk (*) character as a wildcard to substitute any character(s) when specifying a server variable to be ignored. This property is case-insensitive.

LogifyAlert.Instance.IgnoreServerVariables = "HTTP*";

IgnoreRequestBody
(ASP.NET and ASP.NET Core clients only)

Type: Boolean
Default value: false

Specifies whether raw request body content should be ignored.

LogifyAlert.Instance.IgnoreRequestBody = true;

Instance

Type: Singleton

Returns the single instance of the LogifyAlert class.

LogifyAlert client = LogifyAlert.Instance;

OfflineReportsCount

Type: Integer
Default value: 0

Specifies the number of last reports to be kept once an Internet connection is lost. Reports are only saved when the OfflineReportsEnabled property is set to true.

client.OfflineReportsEnabled = true; client.OfflineReportsCount = 20; // Keeps the last 20 reports

OfflineReportsDirectory

Type: String
Default value: "offline_reports"

Specifies a directory path that will be used to store reports once an Internet connection is lost. Reports are only saved when the OfflineReportsEnabled property is set to true.

client.OfflineReportsEnabled = true; client.OfflineReportsDirectory = "<directory-for-offline-reports>";

OfflineReportsEnabled

Type: Boolean
Default value: false

Specifies whether or not Logify should store the last OfflineReportsCount reports once an Internet connection is lost. To send the kept reports once an Internet connection is available, call the SendOfflineReports method.

client.OfflineReportsEnabled = true; client.OfflineReportsCount = 20; // Keeps the last 20 reports client.OfflineReportsDirectory = "<directory-for-offline-reports>";

ProxyCredentials

Type: ICredentials
Default value: null

Specifies proxy credentials (a user name and a password) to be used by Logify Alert to authenticate within your system proxy server. The use of this property resolves the "407 Proxy Authentication Required" proxy error.

client.ProxyCredentials = new NetworkCredential("MyProxyUserName", "MyProxyPassword");

RemoteConfigurationFetchInterval

Type: Integer
Default value: 10

Specifies a time interval, in minutes, in which client configuration set remotely should be automatically loaded from the server. The minimum value is 1.

client.RemoteConfigurationFetchInterval = 5;

Tags

Type: IDictionary<String, String>

Gets the collection of tags specifying additional report fields, which will be used in auto ignoring, filtering or detecting duplicates.

A key is a tag name (a string that consists of a-z, A-Z, 0-9, and _ characters), and a value is a tag value that is saved to a report. A new tag is added with Allow search enabled.

client.Tags["tag_name"] = "tag_value";

UserId

Type: String
Default value: null

Specifies a unique user identifier that corresponds to a sent report.

client.UserId = "user@myapp.com";

Methods

LoadRemoteConfiguration

Loads client configuration parameters specified remotely.

TrackArguments

Collects arguments passed to the invoked method. Call this method when handling an exception that occurs during a method execution.

  • TrackArguments(Exception ex, object instance, params object[] args)
  • TrackArguments(Exception ex, int frameCount, MethodCallInfo call)
  • TrackArguments(Exception ex, MethodCallInfo call, int skipFrames)

public void DoWork(string work) {   LogifyAlert.Instance.ResetTrackArguments();   try {     DoInnerWork(work, 5);     LogifyAlert.Instance.ResetTrackArguments();   }   catch (Exception ex) {     LogifyAlert.Instance.TrackArguments(ex, work);     throw;   } } public void DoInnerWork(string innerWork, int times) {   LogifyAlert.Instance.ResetTrackArguments();   try {     object o = null;     o.ToString();     LogifyAlert.Instance.ResetTrackArguments();   }   catch (Exception ex) {     LogifyAlert.Instance.TrackArguments(ex, this, innerWork, times);     throw;   } }

See the Collect Method Arguments document for details.

ResetTrackArguments

Removes method argument values which TrackArguments collected. Call ResetTrackArguments before a method execution and after method execution succeeds.

Send

Generates a crash report based on the caught exception and sends this report to the Logify Alert service.

  • Send(Exception ex)

    Generates a crash report based on the caught exception and sends this report to the Logify Alert service.

    try {   RunCode(); } catch (Exception e) {   client.Send(e); }

  • Send(Exception ex, IDictionary<String, String> additionalCustomData)

    Sends the caught exception with specified custom data to the Logify Alert service.

    try {   RunCode(); } catch (Exception e) {   var data = new Dictionary<String, String>();   data["FailedOperation"] = "RunCode";   client.Send(e, data); }

  • Send(Exception ex, IDictionary<String, String> additionalCustomData, AttachmentCollection additionalAttachments)

    Sends the caught exception with specified custom data and attachments to the Logify Alert service.

    try {   RunCode(); } catch (Exception e) {   var data = new Dictionary<String, String>();   data["FailedOperation"] = "RunCode";   Attachment newAt = new Attachment();   newAt.Name = "MyAttachedImage.jpg";   newAt.Content = File.ReadAllBytes(@"C:\Work\Image_to_attach.jpg");   // We strongly recommend that you specify the attachment type.   newAt.MimeType = "image/jpeg";   AttachmentCollection newCol = new AttachmentCollection();   newCol.Add(newAt);   client.Send(e, data, newCol); }

SendAsync

Generates a crash report based on the caught exception and sends this report to the Logify Alert service asynchronously.

  • SendAsync(Exception ex)

    Generates a crash report based on the caught exception and sends this report to the Logify Alert service asynchronously.

    try {   RunCode(); } catch (Exception e) {   client.SendAsync(e); }

  • SendAsync(Exception ex, IDictionary<String, String> additionalCustomData)

    Sends the caught exception with specified custom data to the Logify Alert service asynchronously.

    try {
      RunCode(); } catch (Exception e) {   var data = new Dictionary<String, String>();   data["FailedOperation"] = "RunCode";   client.SendAsync(e, data); }

  • SendAsync(Exception ex, IDictionary<String, String> additionalCustomData, AttachmentCollection additionalAttachments)

    Sends the caught exception with specified custom data and attachments to the Logify Alert service asynchronously.

    try {   RunCode(); } catch (Exception e) {   var data = new Dictionary<String, String>();   data["FailedOperation"] = "RunCode";   Attachment newAt = new Attachment();   newAt.Name = "MyAttachedImage.jpg";   newAt.Content = File.ReadAllBytes(@"C:\Work\Image_to_attach.jpg");   // We strongly recommend that you specify the attachment type.   newAt.MimeType = "image/jpeg";   AttachmentCollection newCol = new AttachmentCollection();   newCol.Add(newAt);   client.SendAsync(e, data, newCol); }

SendOfflineReports

Sends all reports saved in the OfflineReportsDirectory folder to the Logify Alert service.

StartExceptionsHandling

Commands Logify Alert to start listening to uncaught exceptions and sends reports for all processed exceptions.

client.StartExceptionsHandling();

StopExceptionsHandling

Commands Logify Alert to stop listening to uncaught exceptions.

client.StopExceptionsHandling();

Events

AfterReportException

Occurs after Logify Alert sends a new crash report to the service.

LogifyAlert.Instance.AfterReportException += OnAfterReportException; void OnAfterReportException(object sender, AfterReportExceptionEventArgs e) {   MessageBox.Show("A new crash report has been sent to Logify Alert", "Crash report", MessageBoxButtons.OK, MessageBoxIcon.Information); }

BeforeReportException

Occurs before Logify Alert sends a new crash report to the service.

The BeforeReportException event occurs between the CanReportException event and sending a new report to the Logify Alert service. If the report send is canceled in the CanReportException event's handler, the report is not sent and the BeforeReportException event isn't raised.

Handle the BeforeReportException event to add custom data to the sent report. To do this, assign the required data to the CustomData property.

LogifyAlert.Instance.BeforeReportException += OnBeforeReportException; void OnBeforeReportException(object sender, BeforeReportExceptionEventArgs e) {   LogifyAlert.Instance.CustomData["LoggedInUser"] = "Mary"; }

CanReportException

Occurs between generating a new crash report and raising the BeforeReportException event.

The CanReportException event occurs right after a new report is generated and is prepared to be sent to the Logify Alert service. Handle the CanReportException event to cancel the report send. To do this, assign true to the appropriate CanReportExceptionEventArgs's Cancel property. Thus, the generated report is not posted to the service and the BeforeReportException isn't raised.

LogifyAlert.Instance.CanReportException += OnCanReportException; void OnCanReportException(object sender, CanReportExceptionEventArgs args) {   if (args.Exception is MyCustomException)     args.Cancel = true; }

ConfirmationDialogShowing
(WinFroms and WPF clients only)

If you set the ConfirmSendReport property to true, the ConfirmationDialogShowing event occurs before showing the confirmation dialog and allows you to customize the confirmation window's appearance.

LogifyAlert.Instance.ConfirmationDialogShowing += Instance_ConfirmationDialogShowing; private void Instance_ConfirmationDialogShowing(object sender, ConfirmationDialogEventArgs e) {   ConfirmWindow w = new ConfirmWindow(e.Model);   // Commands Logify to not show the standard conformation dialog   e.Handled = true;   // Shows the custom confirmation window   w.ShowDialog();   Environment.Exit(1); }

Attributes

LogifyIgnoreAttribute

Indicates that exceptions thrown from a specific method should not be handled and sent to Logify Alert.

[LogifyIgnore(true)] void ThisMethodShouldNotReportAnyExceptions() {   RunSomeCode(); }

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