CodeFoxtrot.FileLogger
1.1.0
dotnet add package CodeFoxtrot.FileLogger --version 1.1.0
NuGet\Install-Package CodeFoxtrot.FileLogger -Version 1.1.0
<PackageReference Include="CodeFoxtrot.FileLogger" Version="1.1.0" />
<PackageVersion Include="CodeFoxtrot.FileLogger" Version="1.1.0" />
<PackageReference Include="CodeFoxtrot.FileLogger" />
paket add CodeFoxtrot.FileLogger --version 1.1.0
#r "nuget: CodeFoxtrot.FileLogger, 1.1.0"
#:package CodeFoxtrot.FileLogger@1.1.0
#addin nuget:?package=CodeFoxtrot.FileLogger&version=1.1.0
#tool nuget:?package=CodeFoxtrot.FileLogger&version=1.1.0
FileLogger - Simple is Good
- 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:LogLevelinappsettings.json. - Live configuration reload via
IOptionsMonitor<FileLoggerOptions>— runtime-tunable settings (LogMinLevel, formatting flags, console colors, custom formatter) update onappsettings.jsonchange without restarting the host. File-lifecycle settings (LogName,LogFolder,LogMaxBytes,LogMaxCount,AutoFlush) are captured at startup. AutoFlushdurability knob — keep the default for per-message durability, or disable for higher throughput under burst load.
Target frameworks
.NET 8, .NET 9, .NET 10.

Single-line Format

Multi-line Format

How to use
Scenario #1: Quickstart with appsettings.json (recommended)
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 | Versions 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. |
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.Extensions.Logging.Configuration (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
-
net9.0
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.15)
- Microsoft.Extensions.Logging (>= 9.0.15)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.15)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.15)
- Microsoft.Extensions.Options (>= 9.0.15)
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.