ImanSoftware.Logging 1.0.1

dotnet add package ImanSoftware.Logging --version 1.0.1
                    
NuGet\Install-Package ImanSoftware.Logging -Version 1.0.1
                    
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="ImanSoftware.Logging" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ImanSoftware.Logging" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ImanSoftware.Logging" />
                    
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 ImanSoftware.Logging --version 1.0.1
                    
#r "nuget: ImanSoftware.Logging, 1.0.1"
                    
#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 ImanSoftware.Logging@1.0.1
                    
#: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=ImanSoftware.Logging&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ImanSoftware.Logging&version=1.0.1
                    
Install as a Cake Tool

ImanSoftware.Logging

Version: 1.0.0 | Last Updated: August 2026

A lightweight logging abstraction for .NET built on top of Microsoft.Extensions.Logging, providing a clean, testable API with full support for scopes and log levels.

ImanSoftware.Logging wraps the standard .NET logging infrastructure behind a simple adapter interface, making application code easier to test while remaining fully compatible with the Microsoft logging ecosystem.


Installation

Install the package using the .NET CLI:

dotnet add package ImanSoftware.Logging

Why LoggerAdapter?

Depending directly on ILogger<T> throughout your application can tightly couple business logic to the logging framework.

Instead of:

private readonly ILogger<ProductService> _logger;

Use:

private readonly ILoggerAdapter<ProductService> _logger;

This abstraction improves testability while preserving all capabilities of the built-in logging system.

Benefits include:

  • Cleaner architecture
  • Easier unit testing
  • Consistent logging API
  • Full support for logging scopes
  • Compatible with Microsoft.Extensions.Logging

Features

  • ILoggerAdapter<TCategoryName>
  • ✅ All standard log levels
  • ✅ Generic Log() method
  • ✅ Structured logging support
  • ✅ Logging scopes (BeginScope)
  • ✅ Open Generic Dependency Injection registration
  • ✅ Built on ILoggerFactory
  • ✅ Lightweight and dependency-free

ILoggerAdapter<TCategoryName>

The primary abstraction for application logging.

Available methods:

  • LogInformation()
  • LogWarning()
  • LogError()
  • LogDebug()
  • LogTrace()
  • LogCritical()
  • Log()
  • BeginScope()

Example:

_logger.LogInformation("Product created.");

_logger.LogWarning("Low inventory.");

_logger.LogError(exception, "Unexpected error.");

LoggerAdapter<TCategoryName>

Default implementation built on top of ILoggerFactory.

Benefits include:

  • Fully compatible with the Microsoft logging infrastructure
  • Works with any configured logging provider
  • Supports structured logging
  • Supports scopes
  • Easy to replace during testing

Logging Scopes

Scopes allow related log entries to share contextual information.

Example:

using (_logger.BeginScope(new
{
    ProductId = id
}))
{
    _logger.LogInformation("Fetching product...");

    _logger.LogInformation("Product loaded.");
}

Every log entry inside the scope automatically includes the scope properties, making log analysis and tracing much easier.


Dependency Injection

Register the adapter in your application:

services.AddLoggerAdapter();

The adapter is registered as an Open Generic, allowing it to be injected into any service:

ILoggerAdapter<ProductService>

Note

If you are using AddImanFramework(), the logger adapter is registered automatically and no additional configuration is required.


Example

using ImanSoftware.Logging;

public class ProductService
{
    private readonly ILoggerAdapter<ProductService> _logger;

    public ProductService(
        ILoggerAdapter<ProductService> logger)
    {
        _logger = logger;
    }

    public async Task<Product> GetProductAsync(int id)
    {
        using (_logger.BeginScope(new
        {
            ProductId = id
        }))
        {
            _logger.LogInformation("Fetching product...");

            // Business logic...
        }
    }
}

Unit Testing

Because logging is abstracted behind an interface, it can easily be mocked.

var mock = new Mock<ILoggerAdapter<ProductService>>();

mock.Setup(x =>
    x.LogInformation(It.IsAny<string>()));

This keeps unit tests simple and independent of the logging infrastructure.


Design Goals

  • Clean abstraction
  • Dependency Injection friendly
  • High performance
  • Structured logging support
  • Scope support
  • Easy to mock
  • Framework independent
  • Clean Architecture compatible
  • Minimal API

Requirements

  • .NET Standard 2.0+
  • .NET 6+
  • .NET 7+
  • .NET 8+
  • .NET 9+
  • .NET 10.0+

Author

Iman Estiri

📧 contact.imanestiri@gmail.com

📧 dev.imanestiri@gmail.com

GitHub:

https://github.com/ImanEstiri


License

This project is licensed under the MIT License.

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 (4)

Showing the top 4 NuGet packages that depend on ImanSoftware.Logging:

Package Downloads
ImanSoftware.Branding

Display ImanSoftware branding badge with contact information in Blazor apps.

ImanSoftware.RateLimiter

Rate limiting abstraction with in-memory and distributed support.

ImanSoftware.Framework

Umbrella package that bundles all ImanSoftware modules for a unified development experience.

ImanSoftware.FileStorage

File storage abstraction for upload, download, delete, move, copy, and metadata operations (local file system included).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 277 8/7/2026
1.0.0 152 8/3/2026