Why Serilog?
Unlike traditional logging libraries, Serilog is built from the ground up to record structured event data. Instead of formatting events immediately into text, Serilog captures the values associated with each named parameter, opening up rich diagnostic possibilities.Key Features
Structured Logging
Capture rich, structured event data with message templates. Properties are preserved for powerful querying and analysis.
Flexible Configuration
Configure loggers using C# code or external configuration with XML/JSON. Easy to set up and customize for any scenario.
Extensive Sink Ecosystem
Write logs to files, console, databases, cloud services, and more. Over 200 community-provided sinks available.
Zero-Overhead When Disabled
Efficient when enabled, extremely low overhead when a logging level is switched off. No performance penalty for disabled logs.
Enrichment Support
Add contextual information to log events with enrichers. Include thread IDs, machine names, correlation IDs, and custom properties.
ASP.NET Core Integration
Best-in-class .NET Core support with rich integration for ASP.NET Core applications. Native support for dependency injection.
Log Levels
Serilog supports six log levels, from most to least verbose:- Verbose - Anything and everything you might want to know about a running block of code
- Debug - Internal system events that aren’t necessarily observable from the outside
- Information - The lifeblood of operational intelligence - things happen
- Warning - Service is degraded or endangered
- Error - Functionality is unavailable, invariants are broken or data is lost
- Fatal - If you have a pager, it goes off when one of these occurs
Quick Example
Here’s a simple example showing Serilog in action:Get Started
Installation
Install Serilog via NuGet and add your first sink
Quick Start
Get up and running with a working logger in minutes
Message Templates
Serilog uses message templates, a simple DSL that extends .NET format strings with named parameters:Supported Platforms
Serilog runs on:- .NET 6.0, 8.0, 9.0, and 10.0
- .NET Framework 4.6.2 and 4.7.1
- .NET Standard 2.0
Serilog is community-backed and actively developed with regular updates and new features.