CodeFoxtrot.FileLogger 1.1.0

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

FileLogger - Simple is Good

Nuget Release

  • Cross-platform implementation supporting asynchronous Console and File logging.
  • Rolling logs with configurable maximum size, maximum count and append of existing log.
  • Configurable default minimum log level.
  • Single-line, Multi-line or Custom log entry formats.
  • Indent multiline messages for easier reading and analysis.
  • Configurable color scheme for Console log messages, for easier reading.
  • Per-provider log level filtering via Logging:FileLogger:LogLevel in appsettings.json.
  • Live configuration reload via IOptionsMonitor<FileLoggerOptions> — runtime-tunable settings (LogMinLevel, formatting flags, console colors, custom formatter) update on appsettings.json change without restarting the host. File-lifecycle settings (LogName, LogFolder, LogMaxBytes, LogMaxCount, AutoFlush) are captured at startup.
  • AutoFlush durability knob — keep the default for per-message durability, or disable for higher throughput under burst load.

Target frameworks

.NET 8, .NET 9, .NET 10.

Snag_1609de2d

Single-line Format

Snag_160b55f8

Multi-line Format

Snag_160d922c

How to use

Bind directly from configuration with the no-arg overload — AddFileLogger() calls AddConfiguration() and registers the options binding for you.

using FileLoggerLibrary;

...<omitted>...

.ConfigureLogging((context, builder) =>
{
    builder.ClearProviders();
    builder.AddFileLogger();
})

appsettings.json -- all options shown

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning"
    },
    "FileLogger": {
      "LogLevel": {
        "Default": "Trace",
        "Microsoft.Hosting.Lifetime": "Information"
      },
      "LogName": "FileLoggerDemo",
      "LogFolder": "",
      "LogMaxBytes": 52428800,
      "LogMaxCount": 10,
      "AutoFlush": true,
      "LogMinLevel": "Trace",
      "UseUtcTimestamp": false,
      "MultiLineFormat": false,
      "IndentMultilineMessages": true,
      "ConsoleLogging": true,
      "EnableConsoleColors": true,
      "LogLevelColors": {
        "Trace": "Cyan",
        "Debug": "Blue",
        "Information": "Green",
        "Warning": "Yellow",
        "Error": "Red",
        "Critical": "Magenta",
        "None": "White"
      }
    }
  }
}

If LogName is omitted, the entry assembly name is used. If LogFolder is omitted, a log directory under the process's current directory is used.

Per-provider log level filtering

The Logging:FileLogger:LogLevel section above scopes filters to just the FileLogger provider. In the example, the file/console output captures Trace and above for application categories, while the global Logging:LogLevel keeps every other registered provider at Information/Warning. The provider's own LogMinLevel is also honored, and AddFileLogger will lower the framework's global MinLevel automatically when needed so trace messages actually reach the dispatcher.

Scenario #2: appsettings.json + an extra inline tweak

Pass an Action<FileLoggerOptions> to override or supplement the bound configuration.

using FileLoggerLibrary;

...<omitted>...

.ConfigureLogging((context, builder) =>
{
    builder.ClearProviders();
    builder.AddFileLogger(context.Configuration, configure =>
    {
        configure.LogEntryFormatter = msg => $"{msg.TimeStamp} :: {msg.Message}";
    });
})

Scenario #3: Pure code-based configuration

For self-contained apps that don't read appsettings.json.

using FileLoggerLibrary;

...<omitted>...

.ConfigureLogging((context, builder) =>
{
    builder.ClearProviders();
    builder.AddFileLogger(configure =>
    {
        configure.LogName = "FileLoggerDemo";
        configure.LogFolder = Path.Combine(Environment.CurrentDirectory, "log");
        configure.LogMaxBytes = 50 * 1048576;
        configure.LogMaxCount = 10;
        configure.AutoFlush = true;
        configure.LogMinLevel = LogLevel.Trace;
        configure.UseUtcTimestamp = false;
        configure.MultiLineFormat = false;
        configure.IndentMultilineMessages = true;
        configure.ConsoleLogging = true;
        configure.EnableConsoleColors = true;
        configure.LogLevelColors = new()
        {
            [LogLevel.Trace] = ConsoleColor.Cyan,
            [LogLevel.Debug] = ConsoleColor.Blue,
            [LogLevel.Information] = ConsoleColor.Green,
            [LogLevel.Warning] = ConsoleColor.Yellow,
            [LogLevel.Error] = ConsoleColor.Red,
            [LogLevel.Critical] = ConsoleColor.DarkRed,
            [LogLevel.None] = ConsoleColor.White,
        };
    });
})

Indentation

IndentMultilineMessages=true

2026-04-29--18.10.20|INFO|FileLoggerDemo.App|{
                                               "Date": "4/29/2026",
                                               "Location": "Center Moriches",
                                               "TemperatureCelsius": 20,
                                               "Summary": "Nice"
                                             }

IndentMultilineMessages=false

2026-04-29--18.11.19|INFO|FileLoggerDemo.App|{
  "Date": "4/29/2026",
  "Location": "Center Moriches",
  "TemperatureCelsius": 20,
  "Summary": "Nice"
}

Note: The IndentMultilineMessages option is only for the Single-Line message format.

Debugging

The package ships Source Link and a matching .snupkg symbol package. With Tools → Options → Debugging → General → Enable Source Link support turned on (and Enable Just My Code turned off), Visual Studio will fetch the exact source revision from GitHub on demand and let you step into FileLogger directly.

Releases

See GitHub Releases for the changelog.

Reference

https://docs.microsoft.com/en-us/dotnet/core/extensions/custom-logging-provider

Product Compatible and additional computed target framework versions.
.NET 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. 
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 CodeFoxtrot.FileLogger:

Package Downloads
CodeFoxtrot.WindowsHelpers

Useful set of helper methods for C# in the Microsoft Windows environment.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 91 4/29/2026
1.0.9 280 11/18/2024
1.0.8 430 12/1/2023
1.0.7 336 4/23/2023
1.0.6 440 12/24/2022
1.0.5 816 7/8/2022
1.0.2 631 4/10/2022
1.0.0 602 4/5/2022