Pacem.Logging.FileSystem 1.0.0-ricci

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

FileSystem Logging Extensions

⚗️ ==Experimental==

⚠️ Experimental libs are discouraged to use in production.

About

Pacem.Logging.FileSystem provides extensions to write your logs to plain text files, with configurable line formatting and file-splitting (by date, level, category or any structured log value).

Log entries are queued and written by a background consumer, so logging calls never block on disk I/O.

ℹ️ This package was previously published as Pacem.Logging.File. Replace that package reference — and any using Pacem.Logging.File; — with the .FileSystem equivalents.

The following paragraphs exemplify the library utilization given common use cases.

How to

Add the relevant logger provider to the logging builder (e.g. ILoggingBuilder) and configure it through FileSystemLoggerOptions:

// Program.cs
builder.Logging.AddPacemFileSystemLogging(options =>
{
    // required: the folder log files are written into (created on first write)
    options.RootFolderPath = "/var/log/myapp";
});

With the defaults, an information entry from category MyApp.Worker lands in

/var/log/myapp/20260903_Information_log.txt

as the line

[2026-09-03T10:15:30.1234567+02:00] - Information - MyApp.Worker: Job started

Options

Option Default Purpose
RootFolderPath (required) Destination folder. Created automatically when missing.
Filename log.txt Base file name. The split criteria are prepended as a prefix.
FileSplitCriteria localDate + logLevel (file name) Ordered list of criteria that build the file-name prefix and/or the subfolders — see below.
FileSizeLimit 0 (unlimited) Byte cap per file. When > 0 the default naming rolls to log001.txt, log002.txt, ... as each file fills up.
FormatMessage [{Timestamp}] - {LogLevel} - {Name}: {Message}\n payload => line. Return an empty/whitespace string to drop the entry from the file.
FormatFilename see remarks Low-level (payload, options) => relativePath, relative to RootFolderPath (subfolders included). Holds the folder + prefix + size-limit logic; override with care.
Filter (none) Func<FileSystemLogPayload, bool> evaluated on the fully-built payload before it is queued. Return false to drop it.

File-splitting criteria

FileSplitCriteria is an ordered collection of FileSplitCriterion entries. Each one has a Key (what to resolve) and a Target (where the value goes):

Target Built with Effect
FileSplitTarget.Filename FileSplitCriterion.Filename(key), or a plain string one segment of the file-name prefix, joined by -
FileSplitTarget.Folder FileSplitCriterion.Folder(key) one subfolder level under RootFolderPath; several folder criteria nest in order

A plain string converts implicitly to a file-name criterion, so FileSplitCriteria.Add("tenant") keeps working as before.

Well-known keys are exposed on KnownFileSplitCriteria:

Constant Value Segment
KnownFileSplitCriteria.LocalDate localDate yyyyMMdd, local time
KnownFileSplitCriteria.UtcDate utcDate yyyyMMdd, UTC
KnownFileSplitCriteria.LogLevel logLevel Information, Error, ...
KnownFileSplitCriteria.Name categoryName the logger category

ℹ️ Any other string is treated as a structured-log-value key: the logger looks it up among the message placeholders and, when found, uses its value as the segment (each whitespace run replaced with a single _).

🛡️ Every segment is sanitized: characters invalid in file names (path separators included) become _, and . / .. become _, so a logged value can never write outside RootFolderPath.

builder.Logging.AddPacemFileSystemLogging(options =>
{
    options.RootFolderPath = "/var/log/myapp";

    // one file per tenant per day, e.g. 20260903-acme-log.txt
    options.FileSplitCriteria.Clear();
    options.FileSplitCriteria.Add(KnownFileSplitCriteria.LocalDate);
    options.FileSplitCriteria.Add("tenant");

    // cap each file at 5 MB and roll (20260903-acme-log001.txt, ...002.txt, ...)
    options.FileSizeLimit = 5 * 1024 * 1024;

    // only persist warnings and above
    options.Filter = log => log.LogLevel >= LogLevel.Warning;
});

// "tenant" is resolved from the structured placeholder
logger.LogWarning("Quota exceeded for {tenant}", "acme");

Folder criteria move values from the file name into subfolders:

builder.Logging.AddPacemFileSystemLogging(options =>
{
    options.RootFolderPath = "/var/log/myapp";

    // one folder per day, one subfolder per tenant, one file per level
    options.FileSplitCriteria.Clear();
    options.FileSplitCriteria.Add(FileSplitCriterion.Folder(KnownFileSplitCriteria.LocalDate));
    options.FileSplitCriteria.Add(FileSplitCriterion.Folder("tenant"));
    options.FileSplitCriteria.Add(KnownFileSplitCriteria.LogLevel); // file name
});
/var/log/myapp/
└── 20260903/
    └── acme/
        ├── Information-log.txt
        └── Warning-log.txt

Missing subfolders are created on first write, and FileSizeLimit rolls files inside their own subfolder.

Plans for version next

Rolling retention (max file count / max age) and an opt-in JSON line format.

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.0.0-ricci 39 10/28/2026
1.0.0-peano 46 10/27/2026
1.0.0-maiorana 46 10/27/2026
0.10.19 44 10/27/2026
0.10.19-galilei 42 10/27/2026
0.10.19-fermi 44 10/27/2026
0.10.19-degiorgi 54 10/26/2026