You are doing logging in .NET wrong. Let’s fix it.
summary
Logging uses the message literal as a message template not an interpolated string; string interpolation or concatenation causes boxing and many heap string allocations that trigger GC pauses (demonstrated as spikes around ~16MB). Use structured logging with named parameters so paymentId and status are indexed separately, push templates once, and search by fields. Prefer Serilog or C# 10+ interpolation handlers and source-generated loggers to avoid runtime boxing and redundant allocations, keeping logs laconic and consistent.
AI-written summary · about
chapters (13)
- 0:00Introduction and talk setup
- 2:51Why logging matters to everyone
- 5:19Logging rule one: message templates
- 10:14Memory management in .NET
- 24:25Logging rule two: avoid string interpolation
- 24:50Structured logging explained
- 30:08Logging rule three: parameter naming
- 33:20Understanding log levels
- 37:09Source generators for logging
- 41:45Custom string interpolation handlers
- 45:16Performance vs correctness in logging
- 47:04Why we log: telling a story
- 51:01Summary and Q&A
related talks
49mYou are doing logging in .NET wrong. Let’s fix it.
01h 05mLook Mommy, No GC!
53m.NET:Stay calm and Serilog + Elastic Search + Kibana on .NET Core
01h 06m.NET Systems Programming Learned the Hard Way
31mSmall things we got wrong in .NET
40mReal-world examples on optimizing .NET performance
01h 02mAbusing C# More
01h 15mCSI .NET – Debugging .NET Applications
