JG.LoggingKit 1.0.0

dotnet add package JG.LoggingKit --version 1.0.0
                    
NuGet\Install-Package JG.LoggingKit -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JG.LoggingKit" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JG.LoggingKit" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="JG.LoggingKit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JG.LoggingKit --version 1.0.0
                    
#r "nuget: JG.LoggingKit, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package JG.LoggingKit@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JG.LoggingKit&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=JG.LoggingKit&version=1.0.0
                    
Install as a Cake Tool

dotnet-logging-kit

NuGet Downloads License CI

A high-performance structured logging library for .NET built on Microsoft.Extensions.Logging. Provides correlation ID tracking for distributed tracing, file rotation, multiple output formatters, log enrichment, scoped context, and hierarchical filtering—all with minimal allocations and full async support.

✨ Features

  • Correlation IDs — Automatic request ID propagation across async boundaries
  • Structured Output — JSON and plain text formatters with exception hierarchies
  • File Rotation — Size-based and time-based rotation with backup retention
  • Log Enrichment — Built-in enrichers for system info, environment, version, and properties
  • Scoped Context — Request-scoped properties with automatic inheritance
  • Advanced Filtering — Per-category and namespace-based log level control
  • Performance — Zero-allocation hot paths with ValueTask<T> optimization
  • Reliability — Thread-safe, async-native, comprehensive error handling
  • Production-Ready — Thoroughly tested, fully documented, battle-hardened

📦 Installation

dotnet add package JG.LoggingKit

🚀 Quick Start

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using JG.Logging.Extensions;

var services = new ServiceCollection();
services.AddStructuredLogging();

var sp = services.BuildServiceProvider();
var logger = sp.GetRequiredService<ILogger<Program>>();

logger.LogInformation("Application started");

📚 Documentation

⚙️ Configuration Examples

Console & File Output

services.AddStructuredLogging(options =>
{
    options.SetMinimumLevel(LogLevel.Information);
    options.AddConsoleSink(new JsonFormatter());
    options.AddFileSink("logs", rollingInterval: RollingInterval.Day);
    options.AddStandardEnrichers();
});

Distributed Tracing

using (CorrelationIdProvider.SetCorrelationId("request-123"))
{
    logger.LogInformation("Processing request");
    // Correlation ID automatically available in async calls
}

Request-Scoped Properties

using (logger.BeginScope(null))
{
    ScopeContextProvider.AddPropertyToCurrentScope("UserId", userId);
    logger.LogInformation("User action"); // Includes UserId
}

🏗️ Architecture

Abstractions

  • ILogFormatter — Format logs to strings
  • ILogSink — Output destinations
  • ILogEnricher — Add contextual properties

Built-In Implementations

  • Formatters: PlainTextFormatter, JsonFormatter
  • Sinks: ConsoleSink, FileSink
  • Enrichers: MachineNameEnricher, EnvironmentEnricher, VersionEnricher, ScopeContextEnricher

📊 Performance

  • Hot Path: Sub-microsecond log level checks
  • Memory: Zero allocations for filtered logs
  • Concurrency: Lock-free correlation ID propagation
  • Throughput: Validated via benchmarks

🧪 Testing

All features are thoroughly tested:

dotnet test -c Release

36 tests covering:

  • File rotation and backups
  • All enrichers and formatters
  • Concurrent access patterns
  • Edge cases and error scenarios
  • Resource disposal

🤝 Contributing

Contributions welcome! Please:

  • Compile with TreatWarningsAsErrors=true
  • Include XML documentation
  • Add tests for new features
  • Follow PROMPT.md standards

📄 License

Licensed under Apache License 2.0. See LICENSE.


Get started → | API docs →

Product 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 80 2/24/2026