NLog.Targets.AppCenter.Crashes 5.1.35-pre

This is a prerelease version of NLog.Targets.AppCenter.Crashes.
dotnet add package NLog.Targets.AppCenter.Crashes --version 5.1.35-pre                
NuGet\Install-Package NLog.Targets.AppCenter.Crashes -Version 5.1.35-pre                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NLog.Targets.AppCenter.Crashes" Version="5.1.35-pre" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NLog.Targets.AppCenter.Crashes --version 5.1.35-pre                
#r "nuget: NLog.Targets.AppCenter.Crashes, 5.1.35-pre"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NLog.Targets.AppCenter.Crashes as a Cake Addin
#addin nuget:?package=NLog.Targets.AppCenter.Crashes&version=5.1.35-pre&prerelease

// Install NLog.Targets.AppCenter.Crashes as a Cake Tool
#tool nuget:?package=NLog.Targets.AppCenter.Crashes&version=5.1.35-pre&prerelease                

NLog.Targets for Microsoft AppCenter

Version Downloads Downloads

NLog targets for Microsoft AppCenter.

Download and Install

There are two separate libraries: NLog.Targets.AppCenter.Analytics for user tracking via NLog loggers and NLog.Targets.AppCenter.Crashes for error logging and crash reporting. The libraries are available on NuGet.org. Use the following command to install the NuGet packages using NuGet package manager console:

PM> Install-Package NLog.Targets.AppCenter.Analytics
PM> Install-Package NLog.Targets.AppCenter.Crashes

You can use these libraries in any .NET project compatible to .NET Standard 2.0 and higher.

Setup NLog AppCenter Analytics/Crashes in .NET MAUI

  1. In your MauiProgram.cs, redirect Microsoft.Extensions.Logging loggers to NLog by adding AddNLog();. The rest of the logging configuration may remain the same as it is.

    builder.Services.AddLogging(configure =>
    {
        configure.ClearProviders();
        configure.SetMinimumLevel(LogLevel.Trace);
        configure.AddNLog();
    });
    
  2. Configure NLog targets either via C# code or with an NLog.config file. For both ways you can find a sample configuration in the sample MAUI app provided in this repository (see Samples/MauiSampleApp/MauiProgram.cs). You can configure both NLog targets, AppCenterAnalyticsTarget and AppCenterCrashesTarget, independently. Create a new instance of the target, set all required configuration properties and add the target to the NLog LoggingConfiguration. Finally, set a logging rule for the new NLog target with an appropriate minimum log level.

    var appCenterCrashesTarget = new AppCenterCrashesTarget();
    appCenterCrashesTarget.AppSecret = "android=....;ios=....";
    appCenterCrashesTarget.ServiceTypes = new[] 
    {
        typeof(Microsoft.AppCenter.Crashes.Crashes)
    };
    // ...
    appCenterCrashesTarget.ContextProperties.Add(new TargetPropertyWithContext
    {
        Name = "date",
        Layout = "${longdate:universalTime=True}"
    });
    // ...
    
    config.AddTarget("AppCenterCrashesTarget", appCenterCrashesTarget);
    var appCenterCrashesRule = new LoggingRule("*", LogLevel.Warn, appCenterCrashesTarget);
    config.LoggingRules.Add(appCenterCrashesRule);
    

Configuration options for AppCenterAnalyticsTarget

  • AppSecret: The app secret for starting AppCenter, e.g. "android={Your Android app secret here};ios={Your iOS app secret here}".
  • ServiceTypes: The service type(s) to be used when calling. Default: typeof(Microsoft.AppCenter.Crashes.Crashes).
  • UserId: Application UserId to register in AppCenter (optional).
  • LogUrl: Base URL (scheme + authority + port only) to the AppCenter-backend (optional).
  • CountryCode: Two-letter ISO country code to send to the AppCenter-backend (optional).
  • TrackOnlyIfMessageStartsWith: Tracks messages only if they're start with this prefix, e.g. "[Track]" (optional).

Configuration options for AppCenterCrashesTarget

  • AppSecret: The app secret for starting AppCenter, e.g. "android={Your Android app secret here};ios={Your iOS app secret here}".
  • ServiceTypes: The service type(s) to be used when calling. Default: typeof(Microsoft.AppCenter.Crashes.Crashes).
  • UserId: Application UserId to register in AppCenter (optional).
  • LogUrl: Base URL (scheme + authority + port only) to the AppCenter-backend (optional).
  • CountryCode: Two-letter ISO country code to send to the AppCenter-backend (optional).
  • WrapExceptionFromLevel: Tracks all log messages which don't contain exception parameter but have a log level equal or higher than the configured value.
  • AttachmentsDirectory: The path of the attachments directory. If set, files in this directory will automatically be attached in the error report sent to AppCenter.
  • AttachmentsFilePattern: File search pattern within the configured AttachmentsDirectory. Default: "*" (All files included).

Good to know

  • If you struggle to get things up and running, have a look at the sample app in this repository. I contains a very close-to-production configuration.
  • If you don't want these NLog targets to start AppCenter automatically, just don't set an AppSecret in the configurations. It will be in your hands to start AppCenter with the correct app secret then.
  • If you only want to use one of the NLog targets (e.g. AppCenterCrashesTarget) but you want to use AppCenter user tracking elsewhere in your app, configure ServiceTypes with both service types (typeof(Microsoft.AppCenter.Analytics.Analytics) and typeof(Microsoft.AppCenter.Crashes.Crashes) so that AppCenter is started with both services. AppCenter cannot be reconfigured with new service types after it's been started.

Contribution

Contributors welcome! If you find a bug or you want to propose a new feature, feel free to do so by opening a new issue on github.com.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.1.35-pre 66 12/1/2024
5.1.34-pre 61 11/1/2024
5.1.33-pre 71 10/1/2024
5.1.32-pre 92 9/1/2024
5.1.31-pre 80 8/1/2024
5.1.30-pre 105 7/1/2024
5.1.29-pre 70 6/1/2024
5.1.28-pre 100 5/1/2024
5.1.27-pre 114 4/1/2024
5.1.26 206 3/29/2024
5.1.24-pre 98 3/27/2024
5.1.23-pre 110 3/14/2024
5.1.22-pre 105 3/11/2024
5.1.21 133 3/10/2024
5.1.19-pre 96 3/10/2024
5.1.17-pre 101 3/10/2024
5.1.15-pre 106 3/1/2024
5.1.14-pre 101 2/26/2024
5.1.13-pre 109 2/1/2024
5.1.12 135 1/28/2024
5.1.11-pre 144 1/1/2024
5.1.10-pre 138 12/1/2023
5.1.9-pre 128 11/1/2023
5.1.7-pre 106 10/29/2023
5.1.6-pre 114 10/24/2023
5.1.5-pre 122 10/19/2023
5.1.4 267 10/17/2023
5.1.3-pre 109 10/17/2023
5.1.2-pre 102 10/17/2023
5.1.1-pre 121 10/17/2023
5.1.0-pre 102 10/17/2023
5.0.14 145 10/16/2023
5.0.12-pre 109 10/16/2023
5.0.7-pre 88 10/16/2023
5.0.6-pre 101 10/16/2023

5.1
- Send attachments along with TrackError to AppCenter

5.0
- Initial release