NLog.Targets.AppCenter.Crashes
5.1.24-pre
See the version list below for details.
dotnet add package NLog.Targets.AppCenter.Crashes --version 5.1.24-pre
NuGet\Install-Package NLog.Targets.AppCenter.Crashes -Version 5.1.24-pre
<PackageReference Include="NLog.Targets.AppCenter.Crashes" Version="5.1.24-pre" />
paket add NLog.Targets.AppCenter.Crashes --version 5.1.24-pre
#r "nuget: NLog.Targets.AppCenter.Crashes, 5.1.24-pre"
// Install NLog.Targets.AppCenter.Crashes as a Cake Addin #addin nuget:?package=NLog.Targets.AppCenter.Crashes&version=5.1.24-pre&prerelease // Install NLog.Targets.AppCenter.Crashes as a Cake Tool #tool nuget:?package=NLog.Targets.AppCenter.Crashes&version=5.1.24-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 | 57 | 11/1/2024 |
5.1.33-pre | 67 | 10/1/2024 |
5.1.32-pre | 88 | 9/1/2024 |
5.1.31-pre | 76 | 8/1/2024 |
5.1.30-pre | 99 | 7/1/2024 |
5.1.29-pre | 66 | 6/1/2024 |
5.1.28-pre | 96 | 5/1/2024 |
5.1.27-pre | 111 | 4/1/2024 |
5.1.26 | 181 | 3/29/2024 |
5.1.24-pre | 93 | 3/27/2024 |
5.1.23-pre | 103 | 3/14/2024 |
5.1.22-pre | 102 | 3/11/2024 |
5.1.21 | 128 | 3/10/2024 |
5.1.19-pre | 93 | 3/10/2024 |
5.1.17-pre | 98 | 3/10/2024 |
5.1.15-pre | 103 | 3/1/2024 |
5.1.14-pre | 98 | 2/26/2024 |
5.1.13-pre | 106 | 2/1/2024 |
5.1.12 | 130 | 1/28/2024 |
5.1.11-pre | 139 | 1/1/2024 |
5.1.10-pre | 135 | 12/1/2023 |
5.1.9-pre | 125 | 11/1/2023 |
5.1.7-pre | 103 | 10/29/2023 |
5.1.6-pre | 111 | 10/24/2023 |
5.1.5-pre | 119 | 10/19/2023 |
5.1.4 | 262 | 10/17/2023 |
5.1.3-pre | 104 | 10/17/2023 |
5.1.2-pre | 99 | 10/17/2023 |
5.1.1-pre | 118 | 10/17/2023 |
5.1.0-pre | 97 | 10/17/2023 |
5.0.14 | 140 | 10/16/2023 |
5.0.12-pre | 106 | 10/16/2023 |
5.0.7-pre | 85 | 10/16/2023 |
5.0.6-pre | 98 | 10/16/2023 |
5.1
- Send attachments along with TrackError to AppCenter
5.0
- Initial release