NLog.Targets.MauiLog
5.2.1
Prefix Reserved
See the version list below for details.
dotnet add package NLog.Targets.MauiLog --version 5.2.1
NuGet\Install-Package NLog.Targets.MauiLog -Version 5.2.1
<PackageReference Include="NLog.Targets.MauiLog" Version="5.2.1" />
paket add NLog.Targets.MauiLog --version 5.2.1
#r "nuget: NLog.Targets.MauiLog, 5.2.1"
// Install NLog.Targets.MauiLog as a Cake Addin #addin nuget:?package=NLog.Targets.MauiLog&version=5.2.1 // Install NLog.Targets.MauiLog as a Cake Tool #tool nuget:?package=NLog.Targets.MauiLog&version=5.2.1
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
How to setup NLog in MAUI
Install the NLog packages
Install-Package NLog.Targets.MauiLog
Install-Package NLog.Extensions.Logging
or in your csproj:
<PackageReference Include="NLog.Targets.MauiLog" Version="5.*" /> <PackageReference Include="NLog.Extensions.Logging" Version="5.*" />
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;
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(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
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-android31.0 is compatible. net6.0-ios was computed. net6.0-ios16.1 is compatible. net6.0-maccatalyst was computed. net6.0-maccatalyst16.1 is compatible. net6.0-macos was computed. net6.0-macos13.0 is compatible. 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. monoandroid90 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. xamarinios10 is compatible. |
Xamarin.Mac | xamarinmac was computed. xamarinmac20 is compatible. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- NLog (>= 5.2.2)
-
MonoAndroid 9.0
- NLog (>= 5.2.2)
-
net6.0-android31.0
- NLog (>= 5.2.2)
-
net6.0-ios16.1
- NLog (>= 5.2.2)
- System.Runtime.InteropServices.NFloat.Internal (>= 6.0.1)
-
net6.0-maccatalyst16.1
- NLog (>= 5.2.2)
- System.Runtime.InteropServices.NFloat.Internal (>= 6.0.1)
-
net6.0-macos13.0
- NLog (>= 5.2.2)
- System.Runtime.InteropServices.NFloat.Internal (>= 6.0.1)
-
Xamarin.iOS 1.0
- NLog (>= 5.2.2)
-
Xamarin.Mac 2.0
- 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.
- Added support for UnhandledExceptionEventHandler in RegisterMauiLog
- Updated to NLog v5.2.2
- Added nuget-package README.md
See https://github.com/NLog/NLog.Targets.MauiLog for documentation of NLog targets for MAUI