Back to Hobby Projects

.NET Logging Framework

EzLogger

EzLogger is a lightweight asynchronous logging library for .NET that handles all writes on a background thread. It exposes six severity levels, writes to console and file targets, and includes automatic log cleanup with minimal configuration.

EzLogger preview image

Project Brief

Platform
.NET Standard 2.0+ / .NET 6+
Type
Open source library
Year
2024
Distribution
NuGet package and GitHub
6severity levels
2output targets

1.Project Overview

Most logging libraries either demand extensive configuration or couple log writes directly to application threads, adding latency under load. EzLogger was built to solve both problems: it runs with minimal setup and processes every log message on a background thread so the caller never waits on I/O.

The framework targets .NET Standard 2.0 and .NET 6+, making it usable across a wide range of applications. Logs are written to both the console and date-based files, with an independent cleaner service that enforces a configurable disk-space cap. The result is a small, self-contained library that handles the full logging lifecycle without external dependencies.

2.Queue-Based Architecture

At its core, EzLogger follows a queue-based architecture. When the application emits a log message, the message is timestamped, converted into an internal log record, and placed into a thread-safe logging pipeline. Multiline messages are split into individual log lines while preserving their original timestamp, ensuring that output remains clear and structured. Because log generation is decoupled from log writing, the calling thread can continue its normal work immediately instead of being blocked by console or file I/O.

  • Non-blocking writes: The calling thread returns immediately; the background service handles all formatting and I/O.
  • Consistent line timestamps: Every line of a multiline message carries the same original timestamp.
  • Safe concurrency: A single producer-consumer queue serializes access to the console and file targets.
EzLogger internal process flow diagram showing the queue-based pipeline from log emission through batch processing to console and file output targets.

Figure 1: EzLogger Internal Process Flow

3.Key Features & Persistence

Background Logger Service

A dedicated background service processes, batches, and dispatches log entries to independent console and file targets. This keeps the application thread free from formatting and I/O work.

Automated Log Retention

A separate cleaner service enforces a configurable disk-space limit. It periodically measures the total size of the log directory and removes the oldest files when the limit is exceeded, preventing unbounded growth in long-running applications.

File-Based Persistence

Each day gets its own log file in an application-specific directory. Console output uses color-coded severity levels for quick scanning; file output stores the same records in plain text for auditing and debugging.

Conclusion

EzLogger trades extensive configurability for predictability. The queue-based pipeline, background service, dual outputs, and automated retention give .NET applications logging that works reliably from the first call without setup code or external dependencies.