NLog.Targets.AppCenter.Crashes
5.1.34-pre
dotnet add package NLog.Targets.AppCenter.Crashes --version 5.1.34-pre
NuGet\Install-Package NLog.Targets.AppCenter.Crashes -Version 5.1.34-pre
<PackageReference Include="NLog.Targets.AppCenter.Crashes" Version="5.1.34-pre" />
paket add NLog.Targets.AppCenter.Crashes --version 5.1.34-pre
#r "nuget: NLog.Targets.AppCenter.Crashes, 5.1.34-pre"
// Install NLog.Targets.AppCenter.Crashes as a Cake Addin #addin nuget:?package=NLog.Targets.AppCenter.Crashes&version=5.1.34-pre&prerelease // Install NLog.Targets.AppCenter.Crashes as a Cake Tool #tool nuget:?package=NLog.Targets.AppCenter.Crashes&version=5.1.34-pre&prerelease
NLog.Targets for Microsoft AppCenter
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
In your
MauiProgram.cs
, redirect Microsoft.Extensions.Logging loggers to NLog by addingAddNLog();
. 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(); });
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)
andtypeof(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 | Versions 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. |
-
.NETStandard 2.0
- Microsoft.AppCenter.Crashes (>= 5.0.2)
- NLog (>= 5.2.2)
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.34-pre | 58 | 11/1/2024 |
5.1.33-pre | 68 | 10/1/2024 |
5.1.32-pre | 89 | 9/1/2024 |
5.1.31-pre | 77 | 8/1/2024 |
5.1.30-pre | 100 | 7/1/2024 |
5.1.29-pre | 67 | 6/1/2024 |
5.1.28-pre | 97 | 5/1/2024 |
5.1.27-pre | 112 | 4/1/2024 |
5.1.26 | 182 | 3/29/2024 |
5.1.24-pre | 94 | 3/27/2024 |
5.1.23-pre | 106 | 3/14/2024 |
5.1.22-pre | 103 | 3/11/2024 |
5.1.21 | 129 | 3/10/2024 |
5.1.19-pre | 94 | 3/10/2024 |
5.1.17-pre | 99 | 3/10/2024 |
5.1.15-pre | 104 | 3/1/2024 |
5.1.14-pre | 99 | 2/26/2024 |
5.1.13-pre | 107 | 2/1/2024 |
5.1.12 | 131 | 1/28/2024 |
5.1.11-pre | 140 | 1/1/2024 |
5.1.10-pre | 136 | 12/1/2023 |
5.1.9-pre | 126 | 11/1/2023 |
5.1.7-pre | 104 | 10/29/2023 |
5.1.6-pre | 112 | 10/24/2023 |
5.1.5-pre | 120 | 10/19/2023 |
5.1.4 | 263 | 10/17/2023 |
5.1.3-pre | 105 | 10/17/2023 |
5.1.2-pre | 100 | 10/17/2023 |
5.1.1-pre | 119 | 10/17/2023 |
5.1.0-pre | 100 | 10/17/2023 |
5.0.14 | 141 | 10/16/2023 |
5.0.12-pre | 107 | 10/16/2023 |
5.0.7-pre | 86 | 10/16/2023 |
5.0.6-pre | 99 | 10/16/2023 |
5.1
- Send attachments along with TrackError to AppCenter
5.0
- Initial release