MintPlayer.AspNetCore.LoggerProviders
11.0.0
See the version list below for details.
dotnet add package MintPlayer.AspNetCore.LoggerProviders --version 11.0.0
NuGet\Install-Package MintPlayer.AspNetCore.LoggerProviders -Version 11.0.0
<PackageReference Include="MintPlayer.AspNetCore.LoggerProviders" Version="11.0.0" />
<PackageVersion Include="MintPlayer.AspNetCore.LoggerProviders" Version="11.0.0" />
<PackageReference Include="MintPlayer.AspNetCore.LoggerProviders" />
paket add MintPlayer.AspNetCore.LoggerProviders --version 11.0.0
#r "nuget: MintPlayer.AspNetCore.LoggerProviders, 11.0.0"
#:package MintPlayer.AspNetCore.LoggerProviders@11.0.0
#addin nuget:?package=MintPlayer.AspNetCore.LoggerProviders&version=11.0.0
#tool nuget:?package=MintPlayer.AspNetCore.LoggerProviders&version=11.0.0
MintPlayer.AspNetCore.LoggerProviders
A Microsoft.Extensions.Logging provider that writes structured entries — timestamp, level,
category, event id, scopes, message and exception — to a file.
Installation
dotnet add package MintPlayer.AspNetCore.LoggerProviders
Quick start
var builder = WebApplication.CreateBuilder(args);
builder.Logging.AddFileProvider(options =>
{
// Required. Resolve it against a root you control — see "The filename" below.
options.FileName = Path.Combine(builder.Environment.ContentRootPath, "Log.txt");
});
There is also a parameterless AddFileProvider() for hosts that configure the options elsewhere
(services.Configure<FileLoggerOptions>(…), or binding a configuration section).
Calling AddFileProvider() twice is harmless: the provider is registered at most once, so no entry
is ever written twice.
Options
| Option | Default | Meaning |
|---|---|---|
FileName |
(none — required) | Path of the log file. Only .txt and .log are accepted, compared case-insensitively. |
MinimumLevel |
LogLevel.Trace |
Lowest level this provider writes, independently of any ILoggingBuilder filter. LogLevel.None disables the provider. |
IncludeScopes |
true |
Whether active BeginScope state is written as part of each entry. |
Bound from configuration by property name, e.g.
{ "FileLogger": { "FileName": "Log.txt", "MinimumLevel": "Information", "IncludeScopes": true } }
builder.Services.AddOptions<FileLoggerOptions>().Bind(builder.Configuration.GetSection("FileLogger"));
builder.Logging.AddFileProvider();
The entry format
One header line per entry, followed by the exception's own lines if there is one, followed by a blank line (the blank line is what delimits a multi-line entry):
<timestamp> [<Level>] <Category>[<EventId>[:<EventName>]] [=> <scope>]* <message>
<exception.ToString()>
<blank>
For example:
2026-08-27T09:15:42.1234567Z [Error] MintPlayer.Sample.Worker[4711:JobFailed] => RequestId:abc request failed
System.InvalidOperationException: the real cause
at MintPlayer.Sample.Worker.Run()
- timestamp — UTC, round-trip (
"O") format, invariant culture. It comes from theTimeProviderregistered in the container, or the system clock when there is none, so a test can pin it. - level — the
LogLevelname:Trace,Debug,Information,Warning,Error,Critical. - category — omitted when empty.
- event id — omitted when the id is
0and unnamed; written as[42]or[42:TheName]. - scopes — outermost first, each prefixed with
=>; omitted whenIncludeScopesis off. - exception —
exception.ToString(), so type, message, stack trace and inner exceptions are all kept. The framework's default message formatter ignores the exception argument, so a logger that writes only the formatted message loses the one thing a log file exists for.
Every field is formatted with the invariant culture, so a file reads identically whatever the host's culture and time zone.
The filename
FileName has no default. An unconfigured provider throws (an OptionsValidationException,
when logging is first resolved) instead of quietly writing a relative Log.txt into whatever
Directory.GetCurrentDirectory() happens to be — which under IIS or a Windows Service is neither
the content root nor necessarily writable. Point it at a root you control:
ContentRootPath, a configured log directory, or an absolute path.
A relative path is accepted if you ask for one explicitly, and is resolved to an absolute path once, when the provider is created; the log file therefore never moves if the process later changes its working directory. The directory must exist — the provider does not create it.
Everything about the filename (presence, extension, resolution) is validated once, at that point, rather than on every write.
Concurrency and disposal
Writes are serialised on a lock shared by every logger targeting the same resolved path, and each
entry is a single open, append, close with FileShare.ReadWrite. So:
- concurrent loggers cannot lose an entry to a sharing violation;
- readers are never locked out —
File.ReadAllText, an editor ortailcan read the file while the application is running; - nothing is buffered, so an entry is on disk before
Logreturns, and disposing the provider owes no flush.
A foreign process that holds the file with a share mode excluding writers still wins; the resulting
IOException surfaces to the caller rather than being swallowed.
Scopes
The provider implements ISupportExternalScope, so it writes the logger factory's shared scope
stack: a scope opened anywhere is recorded on every entry made inside it, whatever the category.
BeginScope never returns null (with IncludeScopes = false it returns an inert scope).
Registering your own provider
builder.Logging.TryAddProvider(serviceProvider => new MyLoggerProvider(...));
Registers the provider type at most once. Deduplicating matters here: a logger provider registered
twice makes the factory write every entry twice, and registering twice is easy — a library's own
AddX() and the app's explicit call cannot see each other.
| Product | Versions 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. |
-
net10.0
- No dependencies.
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 |
|---|---|---|
| 11.0.1 | 103 | 11/12/2026 |
| 11.0.1-rc.1 | 70 | 10/24/2026 |
| 11.0.1-rc.0 | 94 | 9/17/2026 |
| 11.0.0 | 151 | 8/27/2026 |
| 10.1.0 | 88 | 11/12/2026 |
| 10.0.1 | 174 | 1/19/2026 |
| 10.0.0 | 336 | 11/13/2025 |
| 10.0.0-rc.1 | 186 | 10/2/2025 |
| 9.0.0 | 203 | 11/13/2024 |
| 8.0.1 | 267 | 1/28/2024 |
| 8.0.0 | 200 | 1/28/2024 |