LogMachina.DependencyInjection
1.1.0
dotnet add package LogMachina.DependencyInjection --version 1.1.0
NuGet\Install-Package LogMachina.DependencyInjection -Version 1.1.0
<PackageReference Include="LogMachina.DependencyInjection" Version="1.1.0" />
<PackageVersion Include="LogMachina.DependencyInjection" Version="1.1.0" />
<PackageReference Include="LogMachina.DependencyInjection" />
paket add LogMachina.DependencyInjection --version 1.1.0
#r "nuget: LogMachina.DependencyInjection, 1.1.0"
#:package LogMachina.DependencyInjection@1.1.0
#addin nuget:?package=LogMachina.DependencyInjection&version=1.1.0
#tool nuget:?package=LogMachina.DependencyInjection&version=1.1.0
LogMachina.DependencyInjection
LogMachina.DependencyInjection integrates LogMachina with Microsoft.Extensions.DependencyInjection.
Use this package to register ILogMachina<TSource> and ILogMachinaFactory in a .NET application without manually wiring each implementation.
What this package provides
AddLogMachina(this IServiceCollection services, Action<ILogMachinaRegistrationBuilder<IServiceCollection>> configure)- provider-specific registration through callbacks such as
x => x.WithNLog() - configurable DI lifetime through provider extension overloads
Install
dotnet add package LogMachina.DependencyInjection
You also need at least one concrete LogMachina provider package, for example:
dotnet add package LogMachina.NLog
Usage
using LogMachina.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddLogMachina(x => x.WithNLog());
services.AddHostedService<Worker>();
});
After registration, you can inject typed loggers anywhere in your application:
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");
}
}
Choosing a lifetime
By default, LogMachina services are registered as singletons. You can override that:
using LogMachina.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddLogMachina(x => x.WithNLog(ServiceLifetime.Transient));
Notes
- The provider assembly must be referenced by your application so it can be discovered.
AddLogMachina(...)throwsInvalidOperationExceptionif the callback completes without selecting a provider.- If more than one implementation is found for the same LogMachina service type, registration fails with an
InvalidOperationException. - This package handles DI registration only. Provider-specific behavior and configuration remain the responsibility of the provider package.
| 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)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
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.