Invex.Extensions.Logging.FancyConsole 0.5.0-rc.5

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

Invex Logging Extensions

Useful utilities for Microsoft.Extensions.Logging.

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 FancyConsole and File packages are standard logging providers: they plug into ASP.NET Core, Generic Host, or manually created ILoggerFactory, bind options from the Logging configuration section, pick up configuration changes from sources that support reload, and leave level filtering to the standard logging rules. All three projects target net10.0, net9.0, net8.0, and netstandard2.0. The providers can be used independently or together; Utils creates a separate factory with the providers you choose.

Quick start

Install one or both packages:

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

Register them 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!");

See getting started for defaults and level filtering.

Fancy console logger

AddFancyConsole writes styled, human-friendly output to the console. Pick from four layouts:

Layout Output
Standard (default) A date and category header, then time, level, and message, with a blank line between entries.
SingleLine Time, level, category, and message; message line breaks become spaces. Full and Pretty exceptions follow on separate lines.
Minimal Only the level and message.
Detailed Every available field (category, event, thread, scopes, and message), labeled on separate lines.

Standard:

2026-06-11 +10:00 MyApp.Services.OrderService
09:41:23.123  INF Order 42 submitted

SingleLine:

09:41:23.123 INF MyApp.Services.OrderService: Order 42 submitted

Exceptions can be rendered in Full, Spectre.Console Pretty, one-line Summary, or Hidden form, and entries at or above a chosen level can be routed to standard error. Configure in code:

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

builder.Logging.AddFancyConsole(options =>
{
    options.Layout = FancyConsoleLayout.SingleLine;
    options.IncludeScopes = true;
    options.UseShortCategoryName = true;
    options.LevelStyles[LogLevel.Error] = "bold red";
    options.ExceptionFormat = FancyConsoleExceptionFormat.Pretty;
    options.LogToStandardErrorThreshold = LogLevel.Error;
});

Or under Logging:FancyConsole (provider alias FancyConsole). Values configured by the delegate are applied after values bound from configuration:

{
  "Logging": {
    "FancyConsole": {
      "Layout": "SingleLine",
      "IncludeScopes": true,
      "LevelStyles": {
        "Error": "bold red"
      },
      "ExceptionFormat": "Pretty",
      "LogToStandardErrorThreshold": "Error"
    }
  }
}
Option Default Description
Layout Standard Standard, SingleLine, Minimal, or Detailed.
TimestampFormat null .NET date/time format string; null or empty uses the layout default.
UseUtcTimestamp false Show timestamps in UTC instead of local time.
IncludeScopes false Append active scopes after the category in Standard and SingleLine; Detailed always shows them, and Minimal omits them.
UseShortCategoryName false Shorten categories to the text after their last ..
UseColors true Apply styles when the console supports them; NO_COLOR is honored.
LevelStyles empty Per-level Spectre.Console styles, such as "bold red" or "black on yellow".
ExceptionFormat Full Full, Pretty, Summary, or Hidden.
ExceptionTextStyle "red1" Style for Full and Summary exception text.
LogToStandardErrorThreshold None Entries at or above this level go to standard error; None writes everything to standard output.

Each entry is written as a single unit, so concurrent FancyConsole entries do not interleave, and rendering failures are never thrown into the application. See the fancy console guide for every layout, style, and exception option.

File logger

AddFile writes plain, parseable log lines to rolling files:

[2026-06-11 09:41:23.123 +10:00 INF MyApp.Services.OrderService] Order 42 submitted

File output contains the formatted message. Attached exceptions and event IDs are not appended automatically; include any required details in the message. Messages can span multiple lines. See log output format for examples and parsing guidance.

By default it writes to a Logs directory relative to the current working directory. The active file is named after AppDomain.CurrentDomain.FriendlyName, and rolls over before a write when the existing file is at least 24 hours old or the write would bring it to at least 100 MiB. Retention checks a 10 GiB archive threshold per resolved file name and removes at most one oldest archive when a file is created or rolled. These thresholds are not hard disk quotas; see the rollover guide.

Buffered writing is the default. Dispose the host or ILoggerFactory during graceful shutdown so queued entries are flushed, even when disposal immediately follows the last log call; no delay is needed. Entries still in memory can be lost if the process crashes or is killed.

Configure in code:

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

builder.Logging.AddFile(options =>
{
    options.LogDirectory = "Logs";
    options.LogName = "my-app";
    options.FileSizeLimitBytes = 50L * 1024 * 1024;
    options.RolloverInterval = FileRolloverInterval.Hour;
    options.MaxTotalSizeBytes = 1L * 1024 * 1024 * 1024;
    options.PerGroupLogName["Orders"] = "orders";
    options.PerLevelLogName[LogLevel.Error] = "errors";
});

Or under Logging:File (provider alias File). Values configured by the delegate are applied after values bound from configuration:

{
  "Logging": {
    "File": {
      "LogDirectory": "Logs",
      "LogName": "my-app",
      "FileSizeLimitBytes": 104857600,
      "RolloverInterval": "Day",
      "MaxTotalSizeBytes": 10737418240,
      "PerGroupLogName": {
        "Orders": "orders"
      },
      "PerLevelLogName": {
        "Error": "errors",
        "Critical": "errors"
      }
    }
  }
}
Option Default Description
LogDirectory "Logs" Absolute directory, or a directory relative to the current working directory. Created when needed.
LogName AppDomain.CurrentDomain.FriendlyName Active base name without .log, initialized to the application domain friendly name.
PerGroupLogName empty Suffixes for selected scoped groups, appended to the base name before any level suffix. A mapped null or empty string adds nothing.
PerLevelLogName empty Suffixes for selected levels, appended after the base name and any group suffix. A mapped null or empty string adds nothing.
FileSizeLimitBytes 100 MiB Rolls an existing file before a write that would make it reach this size; an oversized entry or batch is still written in full.
RolloverInterval Day Elapsed interval from file creation: Infinite, Year (365 days), Month (30 days), Day, Hour, or Minute.
MaxTotalSizeBytes 10 GiB Archive cleanup threshold per resolved base name. On creation or rollover, removes at most one oldest archive if the total meets the threshold; excludes active files.

PerLevelLogName values now append to LogName as suffixes instead of replacing it. Update existing full-name mappings to suffixes; for example, use "errors" with LogName = "my-app" to write my-app_errors.log. See migration guidance.

LogName now defaults directly to the application friendly name, and SetLogNameSuffix("worker") produces {AppDomain.CurrentDomain.FriendlyName}_worker.log. DefaultLogName has been removed; see log name migration guidance.

Routing by group

Use BeginGroupScope to set a group for log calls within a scope:

using Invex.Extensions.Logging.File;

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

File names start with LogName, followed by the mapped group suffix and then the mapped level suffix, each separated by an underscore. Missing mappings and null or empty mapped suffixes add no separator or text. Nested groups override outer groups until disposed, and scopes flow across await and logger categories. Dictionary and formatted scopes such as logger.BeginScope("{Group}", "Orders") also work. Scope values affect routing without appearing in the file's log lines. See group routing for the complete rules.

Rollover, retention, and write modes

When rollover occurs, the active {name}.log is renamed to {name}_{yyMMdd-HHmmss}.log; collisions receive _1, _2, and later suffixes. Time rollover uses elapsed durations, not calendar boundaries, and checks occur only when an entry is written. Retention is evaluated independently for each base name and never deletes the active file. Case-only path aliases follow the destination filesystem's behavior for buffered routing, archive naming, and retention. See file rollover and retention.

Buffered mode queues entries for a dedicated background thread that writes batches of up to 10 entries. Use direct mode to attempt each write on the calling thread before the log call returns:

builder.Logging.AddFile(buffered: false);

Both modes make an initial write attempt plus up to five retries, report failures to console/debug output, and drop entries that still cannot be written. A successful write flushes the stream to the operating system without guaranteeing physical disk durability. See buffered versus direct writing and the log format guide.

Logging before the host starts

Invex.Extensions.Logging.Utils lets you create a separate logger for startup and shutdown messages. CreateHostLogger uses the category Host, adds a Microsoft category filter at Warning, and runs your configuration callback. Register the providers you need in that 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...");

Disposing the returned HostLogger disposes its factory and factory-owned providers. It has its own configuration; the application's later host configuration does not automatically apply to it. See logging utilities for configuration, factory ownership, and startup fields.

Filtering

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

{
  "Logging": {
    "LogLevel": {
      "Default": "Information"
    },
    "FancyConsole": {
      "LogLevel": {
        "Microsoft": "Warning"
      }
    },
    "File": {
      "LogLevel": {
        "Default": "Warning",
        "MyApp.Services": "Information"
      }
    }
  }
}

Documentation

To build the documentation locally, use the SDK selected by global.json and run from the repository root:

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

DocFX reads the compiled libraries and their XML comments. Build first to include the latest API and documentation; add --serve to preview the generated site in _site/.

The Atom BuildDocs and ServeDocs targets also require the Release assemblies to be built first.

License

Licensed under the terms of LICENSE.txt.

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 is compatible.  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 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 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.3.0-rc.4 60 11/20/2026
1.3.0-rc.2 64 11/13/2026
1.2.0 94 11/11/2026
1.2.0-rc.11 58 11/11/2026
1.2.0-rc.2 121 10/30/2026
1.1.0 402 10/22/2026
1.1.0-rc.6 68 10/22/2026
1.1.0-rc.4 68 10/22/2026
1.1.0-rc.2 63 10/16/2026
1.0.0 741 10/15/2026
0.6.0-rc.25 63 10/15/2026
0.6.0-rc.23 66 10/14/2026
0.6.0-rc.20 64 10/14/2026
0.6.0-rc.18 48 10/14/2026
0.6.0-rc.15 57 10/14/2026
0.6.0-rc.13 50 10/14/2026
0.6.0-rc.11 61 10/14/2026
0.6.0-rc.7 67 10/13/2026
0.5.0 101 10/6/2026
0.5.0-rc.5 63 10/6/2026
Loading failed