Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nlog/nlog.azureappcenter
NLog target for Microsoft Visual Studio App Center with Azure
https://github.com/nlog/nlog.azureappcenter
appcenter azure csharp dotnet mobile-center net-core netstandard nlog nlog-target
Last synced: about 1 month ago
JSON representation
NLog target for Microsoft Visual Studio App Center with Azure
- Host: GitHub
- URL: https://github.com/nlog/nlog.azureappcenter
- Owner: NLog
- License: bsd-3-clause
- Created: 2019-08-17T14:01:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-05T19:27:32.000Z (8 months ago)
- Last Synced: 2024-12-05T23:45:54.418Z (about 2 months ago)
- Topics: appcenter, azure, csharp, dotnet, mobile-center, net-core, netstandard, nlog, nlog-target
- Language: C#
- Homepage:
- Size: 55.7 KB
- Stars: 10
- Watchers: 5
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NLog.Targets.AppCenter
NLog Target for [Microsoft Visual Studio App Center with Azure](https://azure.microsoft.com/services/app-center/)[![Version](https://badge.fury.io/nu/NLog.Targets.AppCenter.svg)](https://www.nuget.org/packages/NLog.Targets.AppCenter)
[![AppVeyor](https://img.shields.io/appveyor/ci/nlog/nlog-azureappcenter/master.svg)](https://ci.appveyor.com/project/nlog/nlog-azureappcenter/branch/master)⚠️ Microsoft AppCenter will be retired - https://learn.microsoft.com/appcenter/retirement
## How to setup NLog in MAUI
1) **Install the NLog packages**
- `Install-Package NLog.Targets.AppCenter`
- `Install-Package NLog.Extensions.Logging`
or in your csproj:```xml
```2) **Add NLog to the MauiApp**
Update `MauiProgram.cs` to include NLog as Logging Provider:
```csharp
var builder = MauiApp.CreateBuilder();// Add NLog for Logging
builder.Logging.ClearProviders();
builder.Logging.AddNLog();
```If getting compiler errors with unknown methods, then update `using`-section:
```csharp
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Extensions.Logging;
```3) **Load NLog configuration for logging**
Add the `NLog.config`-file into the Application-project as assembly-resource (`Build Action` = `embedded resource`), and load like this:
```csharp
NLog.LogManager.Setup().RegisterAppCenter()
.LoadConfigurationFromAssemblyResource(typeof(App).Assembly);
```
Alternative setup NLog configuration using [fluent-API](https://github.com/NLog/NLog/wiki/Fluent-Configuration-API):
```csharp
var logger = NLog.LogManager.Setup().RegisterAppCenter()
.LoadConfiguration(c => c.ForLogger().FilterMinLevel(NLog.LogLevel.Debug).WriteToAppCenter())
.GetCurrentClassLogger();
```## Configuration options for AppCenter NLog Target
- **AppSecret** - Appsecret for starting AppCenter if needed (optional)
- **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)
- **DataResidencyRegion** - Country Code or other identifier of data residency region (optional)
- **ReportExceptionAsCrash** - Report all exceptions as crashes to AppCenter (default=false)
- **IncludeEventProperties** - Include LogEvent properties in AppCenter properties (default=true)
- **IncludeScopeProperties** - Include MappedDiagnosticsLogicalContext (MLDC) that can be provided with MEL BeginScope (default=false)## Example NLog.config file
```xml
```