CDS.SQLiteLogging is a SQLite-backed logging library for .NET applications built on Microsoft.Extensions.Logging.
- .NET 10 (
net10.0) - .NET 8 (
net8.0) - .NET Framework 4.8 (
net48)
- SQLite-backed log storage with structured properties and scopes
Microsoft.Extensions.Loggingprovider for DI-based apps- Batching for efficient write throughput
- Configurable housekeeping (retention period or max entry count)
- Configurable SQLite PRAGMAs (journal mode / synchronous mode)
dotnet add package CDS.SQLiteLoggingusing CDS.SQLiteLogging.MEL;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
var dbPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"CDS",
"SQLiteLogging",
"logs.db");
using var sqliteLoggerProvider = MELLoggerProvider.Create(dbPath);
using var serviceProvider = new ServiceCollection()
.AddLogging(builder =>
{
builder.ClearProviders();
builder.AddProvider(sqliteLoggerProvider);
builder.SetMinimumLevel(LogLevel.Information);
})
.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILoggerFactory>()
.CreateLogger("Demo");
logger.LogInformation("Hello from CDS.SQLiteLogging");BatchSize: max entries written per batchMaxCacheSize: max in-memory queued entriesFlushInterval: periodic flush interval
Mode: automatic or manual cleanupRetentionPeriod: age-based cleanup thresholdCleanupInterval: cleanup timer intervalMaxEntries: count-based retention limit
Defaults:
PRAGMA journal_mode = DELETEPRAGMA synchronous = NORMAL
Both can be overridden with DatabaseOptions when creating the provider.
- Source / issues: https://github.com/nooogle/CDS.SQLiteLogging
- NuGet package: https://www.nuget.org/packages/CDS.SQLiteLogging
MIT — see LICENSE.