LogMachina 1.1.0
dotnet add package LogMachina --version 1.1.0
NuGet\Install-Package LogMachina -Version 1.1.0
<PackageReference Include="LogMachina" Version="1.1.0" />
<PackageVersion Include="LogMachina" Version="1.1.0" />
<PackageReference Include="LogMachina" />
paket add LogMachina --version 1.1.0
#r "nuget: LogMachina, 1.1.0"
#:package LogMachina@1.1.0
#addin nuget:?package=LogMachina&version=1.1.0
#tool nuget:?package=LogMachina&version=1.1.0
LogMachina
LogMachina is a lightweight logging abstraction for .NET.
Use this package when you want application code to depend on a small provider-agnostic interface while still keeping the source type of each logger explicit through ILogMachina<TSource>.
What this package provides
ILogMachina<TSource>for typed loggingILogMachinafor the common logging operationsILogMachinaFactoryfor creating typed loggers outside constructor injection
The abstraction exposes a small fixed set of methods:
public interface ILogMachina
{
void Debug(string message);
void Error(string message);
void Error(Exception ex);
void Info(string message);
void Trace(string message);
void Warn(string message);
}
Install
dotnet add package LogMachina
To actually emit logs, add a provider package such as:
dotnet add package LogMachina.NLog
If you want automatic registration with IServiceCollection, also add:
dotnet add package LogMachina.DependencyInjection
Basic usage
Your application code depends only on the abstraction:
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");
.
.
.
Log.Warn("Using fallback path");
}
}
TSource identifies the component producing the log entry, so each class can depend on its own typed logger:
ILogMachina<OrderProcessor>ILogMachina<PaymentService>ILogMachina<Worker>
Factory usage
If you need to create a typed logger dynamically, depend on ILogMachinaFactory:
using LogMachina;
public sealed class DynamicLoggerConsumer
{
private readonly ILogMachinaFactory Factory;
public DynamicLoggerConsumer(ILogMachinaFactory factory)
{
Factory = factory;
}
public void Run()
{
var log = Factory.Create<DynamicLoggerConsumer>();
log.Info("Created from factory");
}
}
Typical package combination
In a real application, LogMachina is usually used together with:
- an actual loggin provider, such as
LogMachina.NLogfor the concrete NLog-backed implementation - optionally, with a DI contianer integration, such as
LogMachina.DependencyInjectionforIServiceCollectionregistration
Example:
using LogMachina;
using LogMachina.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddLogMachina(x => x.WithNLog());
using var provider = services.BuildServiceProvider();
var log = provider.GetRequiredService<ILogMachina<OrderProcessor>>();
log.Info("Resolved from DI");
Scope and limitations
This package defines the abstraction only. It does not:
- write logs by itself
- configure a concrete logging provider
- provide structured logging payloads or provider-specific features
Those concerns belong to the provider package you choose to use.
| 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
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on LogMachina:
| Package | Downloads |
|---|---|
|
LogMachina.SimpleInjector
A simplified logging interface for .NET |
|
|
LogMachina.NLog
A simplified logging interface for .NET |
|
|
LogMachina.DependencyInjection
A simplified logging interface for .NET |
GitHub repositories
This package is not used by any popular GitHub repositories.
Removed provider assembly scanning. Added callback-based provider selection with explicit validation.