SimpleW.Helper.FileLogSink
26.2.0-alpha.20261115-2395
dotnet add package SimpleW.Helper.FileLogSink --version 26.2.0-alpha.20261115-2395
NuGet\Install-Package SimpleW.Helper.FileLogSink -Version 26.2.0-alpha.20261115-2395
<PackageReference Include="SimpleW.Helper.FileLogSink" Version="26.2.0-alpha.20261115-2395" />
<PackageVersion Include="SimpleW.Helper.FileLogSink" Version="26.2.0-alpha.20261115-2395" />
<PackageReference Include="SimpleW.Helper.FileLogSink" />
paket add SimpleW.Helper.FileLogSink --version 26.2.0-alpha.20261115-2395
#r "nuget: SimpleW.Helper.FileLogSink, 26.2.0-alpha.20261115-2395"
#:package SimpleW.Helper.FileLogSink@26.2.0-alpha.20261115-2395
#addin nuget:?package=SimpleW.Helper.FileLogSink&version=26.2.0-alpha.20261115-2395&prerelease
#tool nuget:?package=SimpleW.Helper.FileLogSink&version=26.2.0-alpha.20261115-2395&prerelease
SimpleW.Helper.FileLogSink
Buffered file logging for SimpleW, with a bounded queue and one background writer.
Features
- UTF-8 text logs with timestamps, levels, sources, trace/span IDs and exceptions.
- UTC hourly or daily rotation, optionally combined with an approximate file size limit.
- Optional retention by file count.
- Batched writes, periodic flushing and explicit asynchronous flushing.
- Supports .NET 8, .NET 9 and .NET 10.
Installation
Add a package reference to your project:
<PackageReference Include="SimpleW.Helper.FileLogSink" Version="26.2.0" />
The addon depends on SimpleW 26.2.x and has no additional third-party dependencies.
Getting started
Construct the sink, then register fileSink.Write with Log.AddSink.
The constructor opens the file and reports startup errors before returning.
No initial FlushAsync() call is needed.
using SimpleW.Helper.FileLogSink;
using SimpleW.Observability;
// 1. Open the file and start the background writer.
await using FileLogSink fileSink = new(new FileLogSinkOptions {
FilePath = "logs/server.log",
RollingInterval = FileLogRollingInterval.Day,
MaxFileSizeBytes = 100L * 1024 * 1024,
RetainedFileCountLimit = 30
});
// 2. Send SimpleW logs to this sink.
Log.AddSink(fileSink.Write);
// 3. start using log
Log.Info("MyApp", "Application started");
await using awaits disposal at the end of the scope; construction is synchronous.
By default, the sink rotates daily in UTC and at an estimated 100 MiB, flushes every second
and retains all old files. Set RetainedFileCountLimit to enable deletion of old files.
Size is estimated as one byte per UTF-16 character in the complete formatted log.
Non-ASCII text can exceed this estimate. Rotation never splits an entry.
A buffered StreamWriter handles UTF-8 encoding and groups file writes.
Use one sink/process for each base path. When the queue is full, producers wait
for space. Stop producers and unregister the sink before disposal.
FlushAsync flushes file buffers without forcing a durable hardware write;
abrupt termination can lose buffered events. Background failures are exposed
through LastError and propagated by writes, flushes and disposal.
Migration from the core library
Reference this addon and replace the import used for the three file sink types
with using SimpleW.Helper.FileLogSink;. Keep using SimpleW.Observability;
for logging APIs such as Log and LogEntry.
Documentation
See the FileLogSink addon documentation for usage, rotation, retention and the complete API reference.
Changelog
See changelog.md.
License
MIT.
| 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. net11.0 is compatible. |
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 |
|---|---|---|
| 26.2.0-alpha.20261115-2395 | 63 | 11/15/2026 |
| 26.2.0-alpha.20261112-2357 | 54 | 11/12/2026 |
| 26.1.0-alpha.20261031-2305 | 69 | 10/31/2026 |
| 26.1.0-alpha.20260927-2283 | 72 | 9/27/2026 |
