NLog.Targets.MauiLog 10.2.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package NLog.Targets.MauiLog --version 10.2.0
                    
NuGet\Install-Package NLog.Targets.MauiLog -Version 10.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NLog.Targets.MauiLog" Version="10.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NLog.Targets.MauiLog" Version="10.2.0" />
                    
Directory.Packages.props
<PackageReference Include="NLog.Targets.MauiLog" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NLog.Targets.MauiLog --version 10.2.0
                    
#r "nuget: NLog.Targets.MauiLog, 10.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NLog.Targets.MauiLog@10.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NLog.Targets.MauiLog&version=10.2.0
                    
Install as a Cake Addin
#tool nuget:?package=NLog.Targets.MauiLog&version=10.2.0
                    
Install as a Cake Tool

NLog.Targets.MauiLog

Version AppVeyor

NLog Target for debugging on MAUI / Xamarin Mobile Platforms using the native logging systems:

  • AndroidAndroid.Util.Log → view in Logcat
  • iOS / macOSOSLog → view in Xcode Console or Console.app
  • Other platformsSystem.Diagnostics.Debugger.Log → view in the debugger output

1. Install NLog

Install the following NuGet packages:

dotnet package add NLog.Extensions.Logging
dotnet package add NLog.Targets.MauiLog

Use the package versions appropriate for your .NET version (Use ver. 10 for NET10, and ver. 8 for NET8 etc.).

2. Configure NLog

NLog integrates with the built-in Microsoft.Extensions.Logging infrastructure. Application code continues to use ILogger<T>, while NLog handles log routing, formatting, and writing to configured targets.

Configure NLog in MauiProgram.cs:

using Microsoft.Extensions.Logging;
using NLog;
using NLog.Extensions.Logging;

public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();

    builder.Logging.ClearProviders();

    // Register NLog MauiLog extension and setup as output target
    NLog.LogManager.Setup()
        .RegisterMauiLog()
        .LoadConfiguration(config => config
            .ForLogger()
            .FilterMinLevel(NLog.LogLevel.Info)
            .WriteToMauiLog());

    // Register NLog as Microsoft.Extensions.Logging provider
    builder.Logging.AddNLog();

    builder.UseMauiApp<App>();

    return builder.Build();
}

3. Start logging

NLog is now configured and receives log events from Microsoft.Extensions.Logging. Application code can continue using ILogger<T> as usual.

You are not required to use the ILogger<T>, if you prefer using NLog.LogManager.GetLogger(....) in the application.

See also Logging Unhandled Exceptions

Alternative configuration

The example above uses the Fluent Configuration API. NLog also supports using configuration files like NLog.config or appsettings.json.

When switching from the Fluent Configuration API to loading a aconfiguration file, remove the LoadConfiguration(...) call from the setup.

When using configuration files, explicitly register the MauiLog extension:

NLog.LogManager.Setup()
    .RegisterMauiLog();

This explicit registration is important when using trimming or Native AOT. If an NLog extension is only referenced through a configuration file, the linker can trim away the extension type, causing NLog logging to fail at runtime.

NLog.config

Example NLog.config file:

<nlog throwConfigExceptions="true">
  <targets>
    <target name="mauilog" type="MauiLog" />
  </targets>
  <rules>
    <logger name="*" minLevel="Info" writeTo="mauilog" />
  </rules>
</nlog>

Make sure to add NLog.config file as an Embedded resource in the application project (Build Action = Embedded resource).

Load the embedded configuration during application startup:

NLog.LogManager.Setup()
    .RegisterMauiLog()
    .LoadConfigurationFromAssemblyResource(typeof(App).Assembly);

appsettings.json

NLog AddNLog() loads the "NLog" section when present, with environment overrides.

Example appsettings.json file:

{
  "NLog": {
    "throwConfigExceptions": true,
    "targets": {
      "mauilog": {
        "type": "MauiLog"
      }
    },
    "rules": [
      {
        "logger": "*",
        "minLevel": "Info",
        "writeTo": "mauilog"
      }
    ]
  }
}

See also NLog configuration with appsettings.json

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-maccatalyst26.0 is compatible.  net10.0-macos was computed.  net10.0-macos26.0 is compatible.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

  • net10.0-android36.0

  • net10.0-ios26.0

  • net10.0-maccatalyst26.0

  • net10.0-macos26.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on NLog.Targets.MauiLog:

Repository Stars
ciribob/DCS-SimpleRadioStandalone
An open source Stand alone Radio for DCS integrating with all clickable cockpits and FC3 Aircraft
Version Downloads Last Updated
10.2.1 0 8/17/2026
10.2.0 0 8/16/2026
10.1.4 163 8/9/2026
10.1.3 891 7/12/2026
10.0.3 17,386 11/23/2025
9.0.3 4,221 11/4/2025
8.6.2 22,785 7/20/2025
8.6.1 5,994 6/28/2025
8.6.0 907 6/22/2025
8.0.0 102,366 1/9/2024
7.6.2 430 7/20/2025
7.6.1 220 6/28/2025
7.6.0 268 6/22/2025
7.0.0 1,422 1/9/2024
6.6.2 437 7/20/2025
6.6.1 214 6/28/2025
6.6.0 264 6/22/2025
6.0.0 1,031 1/9/2024
5.2.1 10,645 10/16/2023
5.2.0 7,576 5/30/2023
Loading failed

- Updated NLog v6.2 to reduce AOT build file size.

See https://github.com/NLog/NLog.Targets.MauiLog for documentation of NLog targets for MAUI