Thread-static StringBuilder reuse, cached severity strings, zero-alloc filtered calls. Built for hot paths.
Drop-in ILoggerProvider. One line to wire up with ASP.NET Core, Generic Host, or Minimal APIs.
Export OpenTelemetry log records in logfmt format with trace context, attributes, and exceptions.
Targets .NET 8.0 and .NET 10.0. Nullable reference types, file-scoped namespaces, implicit usings.
Console by default, or any Stream. WithData() builder pattern for default fields across log entries.
Shared write locks across WithData-derived loggers. Safe for concurrent multi-threaded logging.
using Logfmt; var log = new Logger(); log.Info("Server started", "port", "8080"); // Typed values โ int, bool, double, etc. log.Info("Request handled", "status", 200, "ms", 42); // Default fields on every entry var svc = new Logger().WithData("service", "api"); svc.Info("Ready");
using Logfmt.ExtensionLogging; builder.Logging.ClearProviders(); builder.Logging.AddLogfmt(config => { config.LogLevel["Default"] = LogLevel.Information; }); // Then inject and use ILogger as usual _logger.LogInformation("Processing {RequestId}", id);
using Logfmt.OpenTelemetryLogging; builder.Logging.AddOpenTelemetry(options => { options.AddLogfmtConsoleExporter(); });
using Logfmt; var pairs = LogfmtParser.Parse( "level=info msg=\"hello\" user_id=123"); // pairs[0] = { "level", "info" } // pairs[1] = { "msg", "hello" } // pairs[2] = { "user_id", "123" }