Invex.Extensions.Logging.Utils 1.1.0

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

Invex.Extensions.Logging

Build NuGet License: MIT .NET

Useful utilities for Microsoft.Extensions.Logging: a readable, styled console logger, a rolling file logger, and helpers for logging before the host starts. The providers plug into the standard logging pipeline, so they work with ASP.NET Core, the Generic Host, or a manually created ILoggerFactory.

Packages

Package What it does
Invex.Extensions.Logging.FancyConsole A colorful, readable console logger built on Spectre.Console, with multiple layouts, per-level styles, scopes, pretty exceptions, and standard-error routing.
Invex.Extensions.Logging.File A dependency-light file logger with size- and time-based rollover, retention limits, routing by scoped group and log level, and buffered or synchronous writing.
Invex.Extensions.Logging.Utils Helpers for creating a logger before a host is built, owning its factory, and logging startup information.

The providers can be used independently or together; Utils creates a separate factory with the providers you choose.

Features

  • Four console layouts. Standard, SingleLine, Minimal, and Detailed, with per-level Spectre.Console styles.
  • Readable exceptions. Render exceptions in Full, Pretty, one-line Summary, or Hidden form.
  • Standard-error routing. Send entries at or above a chosen level to standard error.
  • Rolling log files. Roll over by size and elapsed time, and purge old archives per resolved file name.
  • Routing by group and level. Send scoped groups and selected levels to their own files with BeginGroupScope and suffix mappings.
  • Buffered or direct writing. Queue entries for a background writer, or write on the calling thread.
  • Standard options pipeline. Bind from Logging:FancyConsole and Logging:File, reload at runtime, and filter with the standard logging rules.
  • Startup logging. Log before the host is built and emit a consistent startup message with LogUtil.

Installation

dotnet add package Invex.Extensions.Logging.FancyConsole
dotnet add package Invex.Extensions.Logging.File
dotnet add package Invex.Extensions.Logging.Utils

Install only the packages you need. All three target net10.0 and netstandard2.0. FancyConsole depends on Spectre.Console; File depends on System.IO.Abstractions; both build on Microsoft.Extensions.Logging.Configuration. Utils depends on Microsoft.Extensions.Logging and Microsoft.Extensions.Hosting.Abstractions.

Quick start

Register the providers with your host. A common setup is readable console output while you watch the app, plus rolling files for later inspection:

using Invex.Extensions.Logging.FancyConsole;
using Invex.Extensions.Logging.File;

var builder = WebApplication.CreateBuilder(args);

builder.Logging.ClearProviders();
builder.Logging.AddFancyConsole();
builder.Logging.AddFile();

var app = builder.Build();

They also work with a manually created logger factory:

using Invex.Extensions.Logging.FancyConsole;
using Invex.Extensions.Logging.File;
using Microsoft.Extensions.Logging;

using var loggerFactory = LoggerFactory.Create(logging => logging
    .AddFancyConsole()
    .AddFile());

var logger = loggerFactory.CreateLogger<Program>();
logger.LogInformation("Hello, world!");

Usage

Style console output

Pick a layout, styles, and an exception format in code or under Logging:FancyConsole. Values set by the delegate are applied after values bound from configuration:

using Invex.Extensions.Logging.FancyConsole;
using Invex.Extensions.Logging.FancyConsole.Configuration;
using Microsoft.Extensions.Logging;

builder.Logging.AddFancyConsole(options =>
{
    options.Layout = FancyConsoleLayout.SingleLine;
    options.UseShortCategoryName = true;
    options.LevelStyles[LogLevel.Error] = "bold red";
    options.ExceptionFormat = FancyConsoleExceptionFormat.Pretty;
    options.LogToStandardErrorThreshold = LogLevel.Error;
});
09:41:23.123 INF OrderService: Order 42 submitted

See Fancy Console Logger for every layout, option, style, and exception format.

Write rolling log files

AddFile writes plain, parseable lines to Logs/{AppDomain.CurrentDomain.FriendlyName}.log. Before a write, it rolls the file over when it is at least 24 hours old or the write would bring it to at least 100 MiB:

[2026-06-11 09:41:23.123 +10:00 INF MyApp.Services.OrderService] Order 42 submitted
using Invex.Extensions.Logging.File;
using Invex.Extensions.Logging.File.Configuration;

builder.Logging.AddFile(options =>
{
    options.LogName = "my-app";
    options.FileSizeLimitBytes = 50L * 1024 * 1024;
    options.RolloverInterval = FileRolloverInterval.Hour;
});

Buffered writing is the default. Dispose the host or ILoggerFactory during graceful shutdown so queued entries are flushed; entries still in memory can be lost if the process crashes or is killed.

See File Logger Configuration, File Rollover and Retention, and Buffered vs. Direct Writing.

Route entries by group and level

Map groups and levels to file name suffixes, then set the group with a scope:

builder.Logging.AddFile(options =>
{
    options.LogName = "my-app";
    options.PerGroupLogName["Orders"] = "orders";
    options.PerLevelLogName[LogLevel.Error] = "errors";
});

using (logger.BeginGroupScope("Orders"))
{
    logger.LogInformation("Order submitted"); // my-app_orders.log
    logger.LogError("Payment failed");       // my-app_orders_errors.log
}

PerLevelLogName values append to LogName as suffixes instead of replacing it, LogName defaults directly to the application friendly name, and DefaultLogName has been removed. See the migration guidance.

See routing groups to separate files for the complete rules.

Log before the host starts

LogUtil.CreateHostLogger creates a logger with category Host and its own factory, filtered to Warning for Microsoft categories. Register the providers you need in the callback:

using Invex.Extensions.Logging.FancyConsole;
using Invex.Extensions.Logging.Utils;
using Microsoft.Extensions.Logging;

using var startupLogger = LogUtil.CreateHostLogger(logging => logging.AddFancyConsole());
startupLogger.LogStartupInfo<Program>();
startupLogger.LogInformation("Configuring services...");

See Logging Utilities for factory ownership and the startup message fields.

Filter levels per provider

Neither provider filters levels itself. Use the standard log filtering rules, scoped to the FancyConsole or File provider alias when needed:

{
  "Logging": {
    "LogLevel": { "Default": "Information" },
    "File": { "LogLevel": { "Default": "Warning" } }
  }
}

See Getting Started.

Documentation

Full documentation: https://invex-games.github.io/logging-extensions/

Guide Contents
Introduction What the packages are for, key concepts, and design principles
Getting Started Installation, registration, defaults, and level filtering
Fancy Console Logger Layouts, options, level styles, scopes, and exceptions
File Logger Configuration Every file option, group and level routing, and migration notes
File Rollover and Retention File naming, size and time rollover, and archive purging
Buffered vs. Direct Writing Write modes, shutdown, and error handling
File Log Output Format The shape of each log line and parsing tips
Logging Utilities Startup logging, factory ownership, and startup information
API Reference Generated reference for every public type

Development

Use the .NET SDK selected by global.json and run from the repository root:

dotnet build Invex.Extensions.Logging.slnx
dotnet test Invex.Extensions.Logging.slnx

The documentation site is built with DocFX from the pages in docs/ and the XML doc comments in src/. DocFX reads the API from the compiled Release assemblies, because its source-based extraction omits methods declared in C# 14 extension blocks such as AddFancyConsole and AddFile. The Atom targets build the libraries in Release before running DocFX:

dotnet run --project _atom -- BuildDocs
dotnet run --project _atom -- ServeDocs

(atom BuildDocs and atom ServeDocs when the Atom tool is installed.) To run DocFX directly, build Release first:

dotnet build Invex.Extensions.Logging.slnx --configuration Release
docfx docfx.json --warningsAsErrors

The site is generated in _site/; add --serve to preview it locally. Files under api/ with a .yml extension are generated; edit the source XML comments or the Markdown pages instead.

License

Licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.2.0-rc.2 43 10/30/2026
1.1.0 251 10/22/2026
1.1.0-rc.6 66 10/22/2026
1.1.0-rc.4 52 10/22/2026
1.1.0-rc.2 50 10/16/2026
1.0.0 317 10/15/2026
0.6.0-rc.25 56 10/15/2026
0.6.0-rc.23 56 10/14/2026
0.6.0-rc.20 53 10/14/2026
0.6.0-rc.18 44 10/14/2026
0.6.0-rc.15 50 10/14/2026
0.6.0-rc.13 46 10/14/2026
0.6.0-rc.11 55 10/14/2026
0.6.0-rc.7 51 10/13/2026
0.5.0 148 10/6/2026
0.5.0-rc.5 55 10/6/2026