Easy.Logging
1.1.1
dotnet add package Easy.Logging --version 1.1.1
NuGet\Install-Package Easy.Logging -Version 1.1.1
<PackageReference Include="Easy.Logging" Version="1.1.1" />
<PackageVersion Include="Easy.Logging" Version="1.1.1" />
<PackageReference Include="Easy.Logging" />
paket add Easy.Logging --version 1.1.1
#r "nuget: Easy.Logging, 1.1.1"
#:package Easy.Logging@1.1.1
#addin nuget:?package=Easy.Logging&version=1.1.1
#tool nuget:?package=Easy.Logging&version=1.1.1
Easy.Logging
Easy.Logging is a high-performance, thread-safe, and asynchronous logging library for .NET applications.
It is designed to handle high-throughput scenarios by leveraging System.Threading.Channels for background processing (Fire-and-Forget), ensuring your application's main thread is never blocked by I/O operations.
Features
- ** High Performance:** Uses
BufferedSinkto offload logging to a background thread, preventing I/O bottlenecks. - ** Thread-Safe:** Safe to use in multi-threaded environments and supports Singleton/Scoped DI lifetimes correctly.
- ** Multi-Sink:** Built-in support for Console, Rolling File, Redis, and Database (EF Core).
- ** Structured Logging:** Supports structured data (
Properties) for advanced querying in log management systems. - ** Colored Console:** Auto-colorized console output based on log severity for better readability.
- ** Cross-Platform:** Supports .NET 8+, .NET 6, .NET Standard 2.0/2.1, and .NET Framework 4.7.2+.
Installation
Install via NuGet Package Manager:
Install-Package Easy.Logging
Or via .NET CLI:
dotnet add package Easy.Logging
Quick Start
1. Registration (Program.cs)
Register the core services and the specific sinks you need. The library automatically wraps heavy sinks (like File/Redis) in a BufferedSink for performance.
using Easy.Logging.Extensions;
var builder = WebApplication.CreateBuilder(args);
// 1. Add Easy Logging Core
builder.Services.AddEasyLogging();
// 2. Add Sinks (Destinations)
builder.Services.AddConsoleLogger(); // Colored Console
builder.Services.AddRollingFileLogger("Logs"); // Daily rolling files (e.g., log-2023-10-01.txt)
builder.Services.AddRedisLogger("localhost:6379", "app-logs"); // Pushes to a Redis List
// builder.Services.AddDatabaseLogger<AppDbContext>(); // Writes to SQL DB via EF Core
var app = builder.Build();
2. Usage (Controller / Service)
Inject the Easy.Logging.Core.ILogger interface (not Microsoft's ILogger) into your classes.
using Easy.Logging.Core;
using Microsoft.AspNetCore.Mvc;
public class OrderController : ControllerBase
{
private readonly ILogger _logger;
public OrderController(ILogger logger)
{
_logger = logger;
}
[HttpPost]
public async Task<IActionResult> CreateOrder(OrderDto order)
{
// 1. Simple Info Log
await _logger.InfoAsync("Processing new order...", context: "OrderController");
try
{
// Business Logic...
throw new Exception("Payment gateway timeout.");
}
catch (Exception ex)
{
// 2. Error Log with Exception
await _logger.ErrorAsync("Failed to process order.", exception: ex.ToString());
}
// 3. Structured Log (Best for searching/filtering)
await _logger.LogAsync(new LogEntry
{
Level = LogLevel.Warn,
Message = "High value transaction detected",
Properties = new Dictionary<string, object>
{
{ "OrderId", order.Id },
{ "Amount", order.Amount },
{ "Currency", "USD" }
}
});
return Ok();
}
}
Architecture
The library follows a modular Logger vs. Sink architecture:
| Component | Description |
|---|---|
| ILogger (CompositeLogger) | The "Manager". It receives log entries from your code and broadcasts them to all registered sinks. |
| ILogSink (The Workers) | The actual destinations where logs are written (e.g., ConsoleSink, FileSink, RedisSink). |
| BufferedSink (The Buffer) | A decorator that wraps slow sinks (File/DB). It holds logs in a memory queue (Channel<T>) and writes them in the background, ensuring your app stays fast. |
| ILogFormatter | Converts the LogEntry object into a string format (Default is JSON). |
Sinks
- ConsoleSink: Logs to the console
- RollingFileSink: Logs to daily rolling files
- RedisSink: Logs to Redis lists
- DatabaseSink: Logs to a database (Entity Framework/EF Core)
- BufferedSink: Buffers logs and writes asynchronously
- CompositeLogger: Dispatches logs to multiple sinks
Database Logging (EF Core)
To use the Database Sink, your DbContext must implement the ILogDbContext interface.
Implement Interface in DbContext:
public class AppDbContext : DbContext, ILogDbContext { public DbSet<LogRecord> Logs { get; set; } // The table for logs }Register in Program.cs:
builder.Services.AddDatabaseLogger<AppDbContext>();
Contributing
Contributions and suggestions are welcome. Please open an issue or submit a pull request.
Contact
For questions, contact us via elmin.alirzayev@gmail.com or GitHub.
License
This project is licensed under the MIT License.
© 2025 Elmin Alirzayev / Easy Code Tools
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7
- EntityFramework (>= 6.5.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
- System.Text.Json (>= 10.0.2)
-
.NETFramework 4.8
- EntityFramework (>= 6.5.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
- System.Text.Json (>= 10.0.2)
-
.NETStandard 2.0
- Microsoft.EntityFrameworkCore (>= 3.1.32)
- Microsoft.EntityFrameworkCore.Relational (>= 3.1.32)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
- System.Text.Json (>= 10.0.2)
-
.NETStandard 2.1
- EntityFramework (>= 6.5.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
- System.Text.Json (>= 10.0.2)
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.2)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
-
net6.0
- Microsoft.EntityFrameworkCore (>= 7.0.8)
- Microsoft.EntityFrameworkCore.Relational (>= 7.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
-
net7.0
- Microsoft.EntityFrameworkCore (>= 7.0.8)
- Microsoft.EntityFrameworkCore.Relational (>= 7.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
-
net8.0
- Microsoft.EntityFrameworkCore (>= 9.0.8)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
-
net9.0
- Microsoft.EntityFrameworkCore (>= 9.0.8)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- StackExchange.Redis (>= 2.8.58)
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.1.1 | 108 | 2/3/2026 |
| 1.1.0 | 100 | 2/2/2026 |
| 1.0.12 | 102 | 1/23/2026 |
| 1.0.11 | 96 | 1/23/2026 |
| 1.0.9 | 220 | 8/11/2025 |
| 1.0.8 | 231 | 8/8/2025 |
| 1.0.7 | 217 | 8/8/2025 |
| 1.0.6 | 226 | 8/8/2025 |
| 1.0.5 | 240 | 8/8/2025 |
| 1.0.4 | 225 | 8/8/2025 |
| 1.0.3 | 234 | 8/8/2025 |
| 1.0.2 | 242 | 8/8/2025 |
| 1.0.1 | 252 | 8/8/2025 |
| 1.0.0 | 275 | 8/8/2025 |
-