Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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





```