A zero-dependency, zero-allocation, AOT-safe C# CLI framework that generates parsing and routing code at compile time via a Source Generator.
Cysharp/ZLogger
Zero-allocation text and structured logger for .NET and Unity, built on Microsoft.Extensions.Logging with UTF8 output.
- Stars
- 1,789
- Forks
- 130
- Open issues
- 5
- Last commit
- 3 days ago
What is it?
ZLogger is a logging library for .NET and Unity that plugs into Microsoft.Extensions.Logging. It takes C# string interpolation as the log message syntax and writes output directly as UTF8 to consoles, files, streams and custom processors, avoiding the UTF16-to-UTF8 conversion cost that typical string-based loggers incur.
It supports both plain-text and structured JSON or MessagePack output, with options to name parameters, dump objects as JSON, and customize key names and timestamp formats. Built-in providers cover Console, File, RollingFile, Stream and InMemory, and a batching processor helps send logs over HTTP. A source generator for the [ZLoggerMessage] attribute produces compile-time log methods, with Native AOT support via System.Text.Json source generation.
ZLogger targets .NET Standard 2.0 and later, with the best performance on .NET 8 and above.
Key features
- 01Uses C# string interpolation for log messages, with parameters captured as structured properties.
- 02Writes UTF8 output directly, avoiding string encoding overhead.
- 03Supports plain-text, JSON and MessagePack formatters.
- 04Provides Console, File, RollingFile, Stream and InMemory output providers.
- 05Includes a source generator for compile-time ZLoggerMessage log methods.
- 06Integrates with ASP.NET Core and the Generic Host through standard logging builders.
Use cases
- Logging high-volume console output in containerized or cloud-native .NET services.
- Writing structured JSON logs to files or cloud logging pipelines.
- Adding fast file logging with rolling by date or size in .NET applications.
- Logging from Unity projects using the same API.
Quick start
- 1
Install the ZLogger NuGet package
dotnet add package ZLogger - 2
Clear default providers and add the ZLogger console provider in your ASP.NET Core startup
In collections
Topics
FAQ
- What is ZLogger?
- Zero-allocation text and structured logger for .NET and Unity, built on Microsoft.Extensions.Logging with UTF8 output. ZLogger is a logging library for .NET and Unity that plugs into Microsoft.Extensions.Logging. It takes C# string interpolation as the log message syntax and writes output directly as UTF8 to consoles, files, streams and custom processors, avoiding the UTF16-to-UTF8 conversion cost that typical string-based loggers incur.
- Is ZLogger free to use? What license does it have?
- ZLogger is open source under the MIT license. Check the license terms before using it in commercial products.
- Is ZLogger still maintained?
- Actively maintained. The last commit to ZLogger was on Nov 4, 2026.
- What can I use ZLogger for?
- Logging high-volume console output in containerized or cloud-native .NET services. Writing structured JSON logs to files or cloud logging pipelines. Adding fast file logging with rolling by date or size in .NET applications. Logging from Unity projects using the same API.
- How do I install ZLogger?
- Install the ZLogger NuGet package: dotnet add package ZLogger Clear default providers and add the ZLogger console provider in your ASP.NET Core startup
- Where can I get ZLogger?
- The source code and installation instructions are on GitHub: https://github.com/Cysharp/ZLogger
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A high-performance, low-allocation YAML 1.2 library for C# focused on .NET and Unity, with source-generated serialization.
A fast, structured, leveled logging library for Go with both a zero-allocation Logger and a looser SugaredLogger API.
Python logging library that replaces the standard logging setup with a single logger, file rotation, colored output and structured logs.
Universal TypeScript and JavaScript logger with pretty terminal output, structured fields-first JSON, secret masking and zero runtime dependencies.
Structured, API-compatible logger for Go with pluggable formatters and hooks, now in maintenance mode.