Introduction
Most .NET apps log through Serilog or NLog today, and both are mature, battle-tested libraries. SinkSharp is a newer structured logging library for .NET, designed as a drop-in replacement for Serilog or NLog, built around one specific goal: make sure logging calls on your hot path never block, even when a sink (file, network, dashboard) is slow or temporarily down.
This post walks through what SinkSharp is, how its async pipeline works, and what you get out of the box: a real-time in-process dashboard, OpenTelemetry export, Slack/Teams alerting, PII masking, and config-driven log levels.
Getting started
dotnet add package SinkSharp.Core
A console app in five lines
using SinkSharp.Core;
using SinkSharp.Sinks.Console;
var logger = SinkSharpBuilder.Create()
.WriteTo(new ColoredConsoleSink())
.Build();
logger.LogInformation("Order {OrderId} placed for {Amount:C}", 12345, 49.99);
ASP.NET Core
builder.Services.AddSinkSharp(options => options
.MinimumLevel(LogLevel.Information)
.WriteTo(new ColoredConsoleSink())
.WriteTo(new RollingFileSink("logs/app.jsonl"), LogLevel.Warning));
var app = builder.Build();
app.UseSinkSharp(); // adds correlation-id middleware
Named template arguments like {OrderId} aren't just string interpolation — they get extracted into a structured Properties dictionary on every log event, which is what makes filtering by OrderId (or any other named property) possible downstream, including in the dashboard described below.
How it works: the striped async queue
Every call to logger.LogInformation(...) creates a LogEvent and hands it to an in-memory async queue. The calling thread never waits on a sink. Internally, the queue is striped across multiple channels and drained by background workers, so under concurrent load from many threads, SinkSharp doesn't serialize everything behind a single queue the way a naive async wrapper would.
If a sink is slow (say, a network sink), the queue absorbs the backpressure instead of propagating it back to your application code. Caller never waits.
The built-in real-time dashboard
DashboardSink dashSink = null!;
builder.Services.AddSinkSharp(options => options
.WithDashboard(out dashSink, minLevel: LogLevel.Information)
.WriteTo(new ColoredConsoleSink(), LogLevel.Debug));
builder.Services.AddSinkSharpDashboard(dashSink);
var app = builder.Build();
app.UseSinkSharpDashboard("/sinksharp/dashboard");
// → https://localhost:5001/sinksharp/dashboard
This mounts a live log viewer directly in your app — no external log aggregator required for local dev or small deployments. It includes a property-filter panel: pick any key that shows up in your structured properties (like OrderId or ClaimId), type a value, and it filters the buffered events client-side, case-insensitive substring match, filters AND-combined.
For worker services or console apps without a web host, the dashboard can also run on its own standalone port.
Running workers and console apps
Everything above also works outside ASP.NET Core — background workers, console tools, and long-running services can use the same SinkSharpBuilder.Create() entry point with the same sinks and dashboard.
Sinks, enrichers, and alerts
| Capability | What it does |
|---|---|
ColoredConsoleSink |
Console output with per-level coloring |
RollingFileSink |
Rolling JSON-lines file output |
DashboardSink |
Powers the in-process real-time dashboard |
OtlpLogSink |
Exports logs to any OpenTelemetry Collector |
SlackWebhookSink |
Posts formatted alerts to a Slack channel |
TeamsWebhookSink |
Posts formatted alerts to a Microsoft Teams channel |
AzureBlobSink |
Durable log archival to Azure Blob Storage |
Enrichers
Built-in enrichers add structured context to every event automatically: correlation IDs, environment/machine name, request ID, request path, elapsed time, user context (user ID/name/role), and PII masking (email, phone, card, SSN patterns masked before they ever reach a sink).
builder.Services.AddSinkSharp(options => options
.WithCorrelationId()
.WithEnvironment("MyApp", env)
.WithPiiMasking()
.WithUserContext());
PII masking happens in-process, before the event reaches any sink — including network sinks like OpenTelemetry — so masked fields never leave the process in the first place.
OpenTelemetry
var otlpOptions = new OtlpLogSinkOptions
{
Endpoint = new Uri("http://localhost:4317"),
Protocol = OtlpProtocol.Grpc,
ServiceName = "MyApp",
ServiceVersion = "1.0.0",
DeploymentEnvironment = env,
};
builder.Services.AddSinkSharp(options => options
.WriteTo(new OtlpLogSink(otlpOptions), LogLevel.Information));
As of v1.0.3, the binary Protobuf writer builds each OTLP message in a pooled ArrayPool<byte> buffer rather than allocating a new array per event, cutting per-event allocations on that export path.
Slack and Teams alerts
builder.Services.AddSinkSharp(options => options
.WriteTo(new ColoredConsoleSink())
.WriteTo(new SlackWebhookSink(new SlackWebhookSinkOptions
{
WebhookUrl = builder.Configuration["Slack:WebhookUrl"]!,
}), LogLevel.Error)); // only Error and Critical reach Slack
Always set a per-sink minimum level on alerting sinks like this — otherwise they receive everything your pipeline's own MinimumLevel allows through, which is a flood of noise for anything chatty. Teams uses the same pattern with TeamsWebhookSink.
Log levels from appsettings.json
As of v1.1.0, you can bind minimum log levels straight from configuration, without writing them in code:
{
"SinkSharp": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"MyApp.Infrastructure": "Warning"
}
}
}
}
builder.Services.AddSinkSharp(options => options
.ReadFrom(builder.Configuration)
.WriteTo(new ColoredConsoleSink()));
This is scoped to minimum-level binding only — not a full external-configuration system for wiring up sinks/enrichers/sampling from JSON. Note that Verbose and Fatal aren't among the supported level names.
Performance
Benchmarked on GitHub Actions CI (AMD EPYC 7763, 2 logical/1 physical core, Ubuntu 26.04.1 LTS, .NET 9.0.23, BenchmarkDotNet v0.15.8), against a comparable async-wrapped baseline:
| Scenario | Result |
|---|---|
| Hot path, 0 properties | 530.5ns vs 3,038.1ns — 5.7× faster |
| Hot path, 1 property | 1,102.6ns vs 2,212.0ns — 2.0× faster |
| Hot path, 3 properties | 1,457.6ns vs 3,078.9ns — 2.1× faster |
| Allocation, 0 properties | 114B vs 161B — 29% less |
| Allocation, 1 property | 192B vs 360B — 47% less |
| Allocation, 3 properties | 365B vs 472B — 23% less |
| Concurrent throughput, 4 threads | 3.893ms vs 12.251ms — 3.1× faster |
| Producer scaling, 32 producers | 19.794ms vs 35.701ms — 1.8× faster |
| Backpressure (10ms sink) | 1.480µs vs 10,095.253µs — caller never waits |
| End-to-end durability | 0 events lost across all 9 producer/sink combinations |
Try it yourself
git clone https://github.com/SinkSharp/SinkSharp-Logging-Samples.git
dotnet run
The samples repo uses the published NuGet packages, so you can run it without cloning the main library.
Wrapping up
SinkSharp is actively developed and published on NuGet — search for SinkSharp.Core to get started.
Top comments (0)