Open.Logging.Extensions 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Open.Logging.Extensions --version 1.0.0
                    
NuGet\Install-Package Open.Logging.Extensions -Version 1.0.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="Open.Logging.Extensions" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Open.Logging.Extensions" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Open.Logging.Extensions" />
                    
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 Open.Logging.Extensions --version 1.0.0
                    
#r "nuget: Open.Logging.Extensions, 1.0.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.
#addin nuget:?package=Open.Logging.Extensions&version=1.0.0
                    
Install Open.Logging.Extensions as a Cake Addin
#tool nuget:?package=Open.Logging.Extensions&version=1.0.0
                    
Install Open.Logging.Extensions as a Cake Tool

Open.Logging

A lightweight set of .NET libraries that enhances the standard logging infrastructure with additional formatters and extensions.

Features

  • Seamless integration with Microsoft.Extensions.Logging
  • Beautiful console output through Spectre Console integration
  • Customizable log formatting and styling
  • Support for log scopes and context
  • Thread-safe logging operations
  • Exception formatting and display

Installation

dotnet add package Open.Logging.Extensions

or for more colorful output:

dotnet add package Open.Logging.Extensions.SpectreConsole

Usage

Basic Setup

using Microsoft.Extensions.Logging;
using Open.Logging.Extensions.SpectreConsole;

// Add to your service collection
services.AddLogging(builder =>
{
    builder.AddSimpleSpectreConsole();
});

// Inject and use
public class MyService
{
    private readonly ILogger<MyService> _logger;
    
    public MyService(ILogger<MyService> logger)
    {
        _logger = logger;
    }
    
    public void DoSomething()
    {
        _logger.LogInformation("Operation started");
        // ...
    }
}

Customizing Log Level Labels

var customLabels = new LogLevelLabels
{
    Information = "INFO",
    Warning = "ATTENTION",
    Error = "PROBLEM"
};

services.AddLogging(builder =>
{
    builder.AddSimpleSpectreConsole(options =>
    {
        options.Labels = customLabels;
    });
});

Custom Theming

var theme = new SpectreConsoleLogTheme
{
    // Configure colors and styles
};

services.AddLogging(builder =>
{
    builder.AddSpectreConsole(options =>
    {
        options.Theme = theme;
    });
});

Buffered Logging

For high-throughput applications:

using Open.Logging.Extensions;

// Get logger from DI
ILogger logger = serviceProvider.GetRequiredService<ILogger<MyService>>();

// Create buffered logger
BufferedLogger bufferedLogger = logger.AsBuffered();

// Use with await using for automatic flushing
await using (bufferedLogger)
{
    bufferedLogger.LogInformation("This will be buffered");
}

Requirements

These may expand in the future. If anyone needs legacy support, please fill out an request in the repo on GitHub.

  • .NET 9.0
  • C# 13.0

License

MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Open.Logging.Extensions:

Package Downloads
Open.Logging.Extensions.SpectreConsole

Provides customizable a Microsoft.Extensions.Logging.Console.ConsoleFormatter for Spectre.Console.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 146 5/28/2025
1.0.1 145 5/21/2025
1.0.0 139 5/21/2025