NLog.Targets.AppCenter.Analytics
5.1.11-pre
See the version list below for details.
dotnet add package NLog.Targets.AppCenter.Analytics --version 5.1.11-pre
NuGet\Install-Package NLog.Targets.AppCenter.Analytics -Version 5.1.11-pre
<PackageReference Include="NLog.Targets.AppCenter.Analytics" Version="5.1.11-pre" />
paket add NLog.Targets.AppCenter.Analytics --version 5.1.11-pre
#r "nuget: NLog.Targets.AppCenter.Analytics, 5.1.11-pre"
// Install NLog.Targets.AppCenter.Analytics as a Cake Addin #addin nuget:?package=NLog.Targets.AppCenter.Analytics&version=5.1.11-pre&prerelease // Install NLog.Targets.AppCenter.Analytics as a Cake Tool #tool nuget:?package=NLog.Targets.AppCenter.Analytics&version=5.1.11-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.Analytics (>= 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 | 56 | 11/1/2024 |
5.1.33-pre | 65 | 10/1/2024 |
5.1.32-pre | 76 | 9/1/2024 |
5.1.31-pre | 60 | 8/1/2024 |
5.1.30-pre | 94 | 7/1/2024 |
5.1.29-pre | 91 | 6/1/2024 |
5.1.28-pre | 91 | 5/1/2024 |
5.1.27-pre | 91 | 4/1/2024 |
5.1.26 | 114 | 3/29/2024 |
5.1.24-pre | 81 | 3/27/2024 |
5.1.23-pre | 86 | 3/14/2024 |
5.1.22-pre | 94 | 3/11/2024 |
5.1.21 | 109 | 3/10/2024 |
5.1.19-pre | 86 | 3/10/2024 |
5.1.17-pre | 89 | 3/10/2024 |
5.1.15-pre | 100 | 3/1/2024 |
5.1.14-pre | 99 | 2/26/2024 |
5.1.13-pre | 133 | 2/1/2024 |
5.1.12 | 123 | 1/28/2024 |
5.1.11-pre | 123 | 1/1/2024 |
5.1.10-pre | 143 | 12/1/2023 |
5.1.9-pre | 142 | 11/1/2023 |
5.1.7-pre | 116 | 10/29/2023 |
5.1.6-pre | 102 | 10/24/2023 |
5.1.5-pre | 108 | 10/19/2023 |
5.1.4 | 239 | 10/17/2023 |
5.1.3-pre | 115 | 10/17/2023 |
5.1.2-pre | 106 | 10/17/2023 |
5.1.1-pre | 97 | 10/17/2023 |
5.1.0-pre | 99 | 10/17/2023 |
5.0.14 | 139 | 10/16/2023 |
5.0.12-pre | 114 | 10/16/2023 |
5.0.7-pre | 91 | 10/16/2023 |
5.0.6-pre | 101 | 10/16/2023 |
5.0
- Initial release