LogMachina.DependencyInjection 1.1.0

dotnet add package LogMachina.DependencyInjection --version 1.1.0
                    
NuGet\Install-Package LogMachina.DependencyInjection -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LogMachina.DependencyInjection" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LogMachina.DependencyInjection" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="LogMachina.DependencyInjection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LogMachina.DependencyInjection --version 1.1.0
                    
#r "nuget: LogMachina.DependencyInjection, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LogMachina.DependencyInjection@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LogMachina.DependencyInjection&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=LogMachina.DependencyInjection&version=1.1.0
                    
Install as a Cake Tool

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(...) throws InvalidOperationException if 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 136 4/3/2026
1.0.2 115 3/26/2026
1.0.0 111 3/24/2026

Removed provider assembly scanning. Added callback-based provider selection with explicit validation.