VanDerHeijden.Logging
10.0.6
dotnet add package VanDerHeijden.Logging --version 10.0.6
NuGet\Install-Package VanDerHeijden.Logging -Version 10.0.6
<PackageReference Include="VanDerHeijden.Logging" Version="10.0.6" />
<PackageVersion Include="VanDerHeijden.Logging" Version="10.0.6" />
<PackageReference Include="VanDerHeijden.Logging" />
paket add VanDerHeijden.Logging --version 10.0.6
#r "nuget: VanDerHeijden.Logging, 10.0.6"
#:package VanDerHeijden.Logging@10.0.6
#addin nuget:?package=VanDerHeijden.Logging&version=10.0.6
#tool nuget:?package=VanDerHeijden.Logging&version=10.0.6
VanDerHeijden.Logging
Core abstractions for high-performance batched logging in .NET 10.
What's in this package
IBatchedLogWriter<T>— implement this interface to create a custom log writerBatchedLogger<T>— background consumer that batches entries and calls your writerBatchedLoggerProvider<T>—ILoggerProvideradapter for use withMicrosoft.Extensions.Logging
This package contains no writer implementation. Install one of the writer packages instead:
| Package | Target |
|---|---|
VanDerHeijden.Logging.File |
Daily rotating text files |
VanDerHeijden.Logging.MongoDb |
MongoDB collection |
VanDerHeijden.Logging.Sql |
SQL Server (SqlBulkCopy) |
VanDerHeijden.Logging.Redis |
Redis list (RPUSH) |
Implementing a custom writer
public sealed class MyWriter : IBatchedLogWriter<string>
{
public async Task WriteBatchAsync(List<string> entries, CancellationToken ct)
{
// write entries to your target
}
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
}
Register it:
builder.Logging.Services.AddSingleton<ILoggerProvider>(sp =>
{
var httpContextAccessor = sp.GetService<IHttpContextAccessor>(); // optional
var writer = new MyWriter();
var logger = new BatchedLogger<string>(writer, batchSize: 200, maxIdleMs: 4000);
return new BatchedLoggerProvider<string>(
logger,
entryFactory: (msg, level, ctx) => msg,
httpContextAccessor);
});
The entryFactory receives an optional HttpLogContext with request metadata (Path, Method, ClientIp,
Referer, UserAgent, SessionId). It is null when no HTTP context is active or when
IHttpContextAccessor is not registered.
Repository
| 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
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- Microsoft.Extensions.Configuration (>= 10.0.4)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.4)
- Microsoft.Extensions.Logging (>= 10.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.4)
- Microsoft.Extensions.Logging.Console (>= 10.0.4)
- Microsoft.Net.Http.Headers (>= 10.0.4)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on VanDerHeijden.Logging:
| Package | Downloads |
|---|---|
|
VanDerHeijden.Logging.MongoDb
MongoDB log writer for VanDerHeijden.Logging: writes batched log entries to a MongoDB collection. |
|
|
VanDerHeijden.Logging.File
File log writer for VanDerHeijden.Logging: writes batched log entries to daily rotating text files. |
|
|
VanDerHeijden.Logging.Redis
Redis log writer for VanDerHeijden.Logging: writes batched log entries to a Redis list using RPUSH. |
|
|
VanDerHeijden.Logging.Sql
SQL Server log writer for VanDerHeijden.Logging: writes batched log entries to a SQL Server table using SqlBulkCopy. |
GitHub repositories
This package is not used by any popular GitHub repositories.