NLog.Targets.MauiLog 8.6.2

NLog.Targets.MauiLog

NLog Target for debugging on MAUI / Xamarin Mobile Platforms:

  • Apple iOS / MacOS - Unified Logging OSLog (replacement of print and NSLog)
  • Android - Android.Util.Log / LogCat
  • NetStandard - System.Diagnostics.Debugger.Log

Version AppVeyor

How to setup NLog in MAUI

  1. Install the NLog packages

    • Install-Package NLog.Targets.MauiLog
    • Install-Package NLog.Extensions.Logging

    or in your csproj (Use ver. 8 for NET8, and ver. 7 for NET7 etc.):

    <PackageReference Include="NLog.Targets.MauiLog" Version="8.*" />
    <PackageReference Include="NLog.Extensions.Logging" Version="6.*" />
    
  2. Add NLog to the MauiApp

    Update MauiProgram.cs to include NLog as Logging Provider:

    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:

    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:

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

    Alternative setup NLog configuration using fluent-API:

    var logger = NLog.LogManager.Setup().RegisterMauiLog()
                     .LoadConfiguration(c => c.ForLogger().FilterMinLevel(NLog.LogLevel.Debug).WriteToMauiLog())
                     .GetCurrentClassLogger();
    

Configuration options for MAUI Log Target

  • Layout - LogEvent message layout
  • Category - LogEvent category layout (optional)

Example NLog.config-file:

<nlog>
<extensions>
    <add assembly="NLog.Targets.MauiLog" />
</extensions>
<targets>
    <target name="mauilog" type="MauiLog" />
</targets>
<rules>
    <logger name="*" minLevel="Info" writeTo="mauilog" />
</rules>
</nlog>

See also Logging Unhandled Exceptions

No packages depend on NLog.Targets.MauiLog.

  • Updated to NLog v6.0.2 with AOT-support

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

.NET 8.0

.NET 8.0

.NET 8.0

.NET 8.0

.NET 8.0

Version Downloads Last updated
10.0.3 0 2025-11-23
9.0.3 0 2025-11-04
8.6.2 3 2025-11-05
8.6.1 0 2025-06-28
8.6.0 0 2025-06-22
8.0.0 0 2024-01-09
7.6.2 0 2025-07-20
7.6.1 0 2025-06-28
7.6.0 0 2025-06-22
7.0.0 0 2024-01-09
6.6.2 0 2025-07-20
6.6.1 0 2025-06-28
6.6.0 0 2025-06-22
6.0.0 0 2024-01-09
5.2.1 0 2023-10-16
5.2.0 0 2023-05-30
1.0.4 0 2023-04-11
1.0.3 0 2023-04-10
1.0.2 0 2022-11-22
1.0.1 0 2022-10-25
1.0.0 0 2022-09-17