LogMachina.NLog
1.1.0
dotnet add package LogMachina.NLog --version 1.1.0
NuGet\Install-Package LogMachina.NLog -Version 1.1.0
<PackageReference Include="LogMachina.NLog" Version="1.1.0" />
<PackageVersion Include="LogMachina.NLog" Version="1.1.0" />
<PackageReference Include="LogMachina.NLog" />
paket add LogMachina.NLog --version 1.1.0
#r "nuget: LogMachina.NLog, 1.1.0"
#:package LogMachina.NLog@1.1.0
#addin nuget:?package=LogMachina.NLog&version=1.1.0
#tool nuget:?package=LogMachina.NLog&version=1.1.0
LogMachina.NLog
LogMachina.NLog provides an NLog-backed implementation of the LogMachina abstractions.
Use this package when your application depends on ILogMachina<TSource> and you want log events to be written through NLog while keeping application code independent from the logging provider.
What this package provides
NLogLogMachina<TSource>as an implementation ofILogMachina<TSource>NLogLogMachinaFactoryas an implementation ofILogMachinaFactory- typed loggers where
TSourceidentifies the component emitting the log entry
Each call to Debug, Info, Trace, Warn, or Error is translated to the corresponding NLog level.
Install
dotnet add package LogMachina.NLog
If you want to resolve LogMachina services from IServiceCollection, also install:
dotnet add package LogMachina.DependencyInjection
Basic usage
You can instantiate the logger directly:
using LogMachina;
using LogMachina.NLog;
var log = new NLogLogMachina<OrderProcessor>();
log.Info("Processing order");
log.Warn("Using fallback path");
Or create it via the factory:
using LogMachina;
using LogMachina.NLog;
ILogMachinaFactory factory = new NLogLogMachinaFactory();
var log = factory.Create<OrderProcessor>();
log.Info("Created from factory");
Example
using LogMachina;
public sealed class OrderProcessor
{
private readonly ILogMachina<OrderProcessor> Log;
public OrderProcessor(ILogMachina<OrderProcessor> log)
{
Log = log;
}
public void Process()
{
Log.Info("Processing order");
}
}
NLog configuration
This package does not replace normal NLog configuration. Configure NLog the same way you already do in your application, for example with:
nlog.configNLog.Config.LoggingConfigurationLogManager.Setup(...)
Once NLog is configured, LogMachina.NLog will emit log entries through that configuration.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- LogMachina (>= 1.1.0)
- NLog (>= 6.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Removed provider assembly scanning. Added callback-based provider selection with explicit validation.