Skip to content

Latest commit

 

History

History
238 lines (174 loc) · 11.7 KB

README.md

File metadata and controls

238 lines (174 loc) · 11.7 KB

← .NET Matrix · Open the interactive matrix →

Logging

ZLogger leads the current rating · 6 libraries · 9 scenarios

Rating

In every scenario the fastest library scores 100 points and the one allocating least scores 100 more; four times slower is half the points, and an unsupported scenario is worth nothing. Time and memory reach 900 each here, so the maximum is 1800. See workflows/rating.md.

Logging rating

# Library Scenarios Time Memory Points Group wins
1 ZLogger 9/9 418 801 1220 gold in Core, silver in Structured
2 Microsoft.Extensions.Logging 7/9 559 584 1143 gold in Structured
3 NLog 9/9 695 420 1115 silver in Core, bronze in Prepare, bronze in Structured
4 Serilog 9/9 559 432 990 gold in Prepare
5 log4net 9/9 435 382 817 silver in Prepare
6 OpenTelemetry 8/9 346 449 796 bronze in Core
How the points were earned — every scenario, with the measurements behind it

Each row is one scenario. Best is the lowest result among the rated libraries that completed it, and the points follow from the two figures beside them: 100 × √((best + step) / (result + step)), with a step of 1 ns for time and 24 B for memory. A dash means the library did not complete the scenario, and it scores nothing for it. Add the two Points columns over every scenario and you get the rating above. The same breakdown appears as a hint on any points value in the application.

1. ZLogger — 1220 of 1800

Scenario Time Best Points Memory Best Points
Disabled Log 1.72 ns 0.01 ns 60.9 0 B 0 B 100
Simple Message 105.89 ns 11.76 ns 34.6 0 B 0 B 100
Structured Properties 122.28 ns 25.56 ns 46.4 0 B 0 B 100
Exception 107.12 ns 11.5 ns 34 0 B 0 B 100
Scope Or Context 173.25 ns 42.49 ns 50 336 B 120 B 63.2
Template Rendering 116.78 ns 22.31 ns 44.5 0 B 0 B 100
Buffered Logging 227.21 ns 68.22 ns 55.1 0 B 0 B 100
Prepare Logger 18.98 μs 585.75 ns 17.6 21.33 KB 3.07 KB 38.1
Formatted Output 206.46 ns 117.06 ns 75.4 0 B 0 B 100

2. Microsoft.Extensions.Logging — 1143 of 1800

Scenario Time Best Points Memory Best Points
Disabled Log 4.83 ns 0.01 ns 41.6 0 B 0 B 100
Simple Message 11.76 ns 11.76 ns 100 0 B 0 B 100
Structured Properties 25.56 ns 25.56 ns 100 88 B 0 B 46.3
Exception 11.5 ns 11.5 ns 100 0 B 0 B 100
Scope Or Context 42.49 ns 42.49 ns 100 120 B 120 B 100
Template Rendering 22.31 ns 22.31 ns 100 0 B 0 B 100
Buffered Logging — 68.22 ns 0 — 0 B 0
Prepare Logger 20.06 μs 585.75 ns 17.1 21.19 KB 3.07 KB 38.2
Formatted Output — 117.06 ns 0 — 0 B 0

3. NLog — 1115 of 1800

Scenario Time Best Points Memory Best Points
Disabled Log 0.01 ns 0.01 ns 100 0 B 0 B 100
Simple Message 30.63 ns 11.76 ns 63.5 120 B 0 B 40.8
Structured Properties 49 ns 25.56 ns 72.9 248 B 0 B 29.7
Exception 31.94 ns 11.5 ns 61.6 120 B 0 B 40.8
Scope Or Context 57.05 ns 42.49 ns 86.6 248 B 120 B 72.8
Template Rendering 48.76 ns 22.31 ns 68.4 232 B 0 B 30.6
Buffered Logging 68.22 ns 68.22 ns 100 120 B 0 B 40.8
Prepare Logger 3.32 μs 585.75 ns 42 24.46 KB 3.07 KB 35.6
Formatted Output 117.06 ns 117.06 ns 100 272 B 0 B 28.5

4. Serilog — 990 of 1800

Scenario Time Best Points Memory Best Points
Disabled Log 0.44 ns 0.01 ns 83.7 0 B 0 B 100
Simple Message 56.33 ns 11.76 ns 47.2 160 B 0 B 36.1
Structured Properties 111.45 ns 25.56 ns 48.6 448 B 0 B 22.5
Exception 60.87 ns 11.5 ns 45 160 B 0 B 36.1
Scope Or Context 122.45 ns 42.49 ns 59.4 544 B 120 B 50.4
Template Rendering 107.68 ns 22.31 ns 46.3 432 B 0 B 22.9
Buffered Logging 242.8 ns 68.22 ns 53.3 160 B 0 B 36.1
Prepare Logger 585.75 ns 585.75 ns 100 3.07 KB 3.07 KB 100
Formatted Output 206.88 ns 117.06 ns 75.4 296 B 0 B 27.4

5. log4net — 817 of 1800

Scenario Time Best Points Memory Best Points
Disabled Log 4.02 ns 0.01 ns 44.8 0 B 0 B 100
Simple Message 76.26 ns 11.76 ns 40.6 160 B 0 B 36.1
Structured Properties 112.41 ns 25.56 ns 48.4 336 B 0 B 25.8
Exception 77.16 ns 11.5 ns 40 160 B 0 B 36.1
Scope Or Context 226.03 ns 42.49 ns 43.8 896 B 120 B 39.6
Template Rendering 86.68 ns 22.31 ns 51.6 272 B 0 B 28.5
Buffered Logging 243.92 ns 68.22 ns 53.2 840 B 0 B 16.7
Prepare Logger 11.77 μs 585.75 ns 22.3 6.79 KB 3.07 KB 67.4
Formatted Output 142.78 ns 117.06 ns 90.6 219 B 0 B 31.4

6. OpenTelemetry — 796 of 1800

Scenario Time Best Points Memory Best Points
Disabled Log 5.1 ns 0.01 ns 40.6 0 B 0 B 100
Simple Message 75.11 ns 11.76 ns 40.9 48 B 0 B 57.7
Structured Properties 138.45 ns 25.56 ns 43.6 216 B 0 B 31.6
Exception 76.13 ns 11.5 ns 40.3 48 B 0 B 57.7
Scope Or Context 108.09 ns 42.49 ns 63.1 168 B 120 B 86.6
Template Rendering 151.82 ns 22.31 ns 39.1 112 B 0 B 42
Buffered Logging 131.17 ns 68.22 ns 72.4 48 B 0 B 57.7
Prepare Logger 143.89 μs 585.75 ns 6.386 125.96 KB 3.07 KB 15.7
Formatted Output — 117.06 ns 0 — 0 B 0

Benchmark overview

Core

Logging Core benchmark overview

More overview charts (2)

Structured

Logging Structured benchmark overview

Prepare

Logging Prepare benchmark overview

Compared libraries (6)

log4net logo log4net 3.5.0
A mature Apache logging framework with hierarchical repositories, contextual properties, layouts, and appenders.
Compare →
Microsoft.Extensions.Logging logo Microsoft.Extensions.Logging 10.0.14
The standard .NET logging abstraction and logger factory with providers, filtering, structured state, and scopes.
Compare →
NLog logo NLog 6.2.2
A configurable logging platform with structured events, scope context, targets, layouts, and asynchronous wrappers.
Compare →
OpenTelemetry logo OpenTelemetry 1.20.1
The OpenTelemetry .NET logging provider and processing pipeline for collecting, enriching, batching, and exporting MEL log records.
Compare →
Serilog logo Serilog 4.4.0
A structured event logger with message templates, contextual enrichment, and a broad sink ecosystem.
Compare →
ZLogger logo ZLogger 2.5.10
A source-generated and interpolated-string logger built on Microsoft.Extensions.Logging with UTF-8 and processor APIs.
Compare →

Benchmark scenarios (9)

01 · Disabled Log

Submits an Information event to a logger whose minimum level is Warning.

Logging Disabled Log benchmark

02 · Simple Message

Delivers one literal Information message to an in-memory sink.

Logging Simple Message benchmark

03 · Structured Properties

Delivers one event with independently queryable OrderId and ElapsedMs properties.

Logging Structured Properties benchmark

04 · Exception

Delivers one Error event retaining the original exception metadata.

Logging Exception benchmark

05 · Scope Or Context

Creates a temporary RequestId context and captures it on one event.

Logging Scope Or Context benchmark

06 · Template Rendering

Formats amount 12.5 and customer Ada through the logger template API.

Logging Template Rendering benchmark

07 · Buffered Logging

Enqueues one event to a library-provided async or buffering wrapper and validates delivery after flush. Measures the cost of accepting the event; the remaining delivery work happens on a background thread.

Logging Buffered Logging benchmark

08 · Prepare Logger

Creates, verifies, and releases one Information-enabled logger with an in-memory sink.

Logging Prepare Logger benchmark

09 · Formatted Output

Formats one event synchronously into a bounded in-memory sink.

Logging Formatted Output benchmark