-
Notifications
You must be signed in to change notification settings - Fork 0
Log Levels
Six severity levels, ordered from most verbose to most severe. Plus None, used only to switch
logging off.
| Level | Numeric | Text tag | Icon | Use it for… |
|---|---|---|---|---|
Trace |
0 | TRACE |
⬜ | The most fine-grained diagnostic detail — method entry/exit, loop values. Normally off in production (noisy/expensive). |
Debug |
1 | DEBUG |
🟦 | Developer-facing diagnostics — cache hits/misses, internal state, chosen code paths. Usually off in production. |
Information |
2 | INFO |
🟩 | Normal application flow and business milestones — "started", "user signed in", "job done". The default minimum level. |
Warning |
3 | WARN |
🟨 | Something unexpected, but the app recovered — a retry, a fallback, a deprecated path, nearing a limit. |
Error |
4 | ERROR |
🟥 | The current operation failed — typically a caught exception. The app keeps running. |
Critical |
5 | CRITICAL |
🟪 | The app or a major subsystem is unusable — out of memory, failed startup, data loss. The "wake someone up" level. |
None |
6 | — | — | Not a real entry. Set as the minimum level to disable all logging. |
Every level has two overloads — a message (with optional template values) and an exception variant:
Log.Trace("Entered {method}", nameof(Process));
Log.Debug("Cache miss for {key}", key);
Log.Information("User {userId} signed in", userId);
Log.Warning("Retry {attempt} of {max}", attempt, max);
Log.Error("Request to {url} failed", url);
Log.Error(ex, "Request to {url} failed", url); // with exception
Log.Critical(ex, "Unrecoverable startup failure");The same methods exist on Log<T> (with plain-string messages — see
Log vs Log<T>).
The configured minimum level is the primary volume control: any entry below it is dropped before any formatting work happens, so suppressed logs are cheap.
Log.Configure(o => o.SetMinimumLevel(LogLevel.Warning));
Log.Information("ignored"); // below minimum → dropped
Log.Warning("kept"); // at/above minimum → writtenBecause the levels are ordered (Trace = 0 … Critical = 5), "minimum level Warning" means
Warning, Error, and Critical are written; Trace, Debug, Information are dropped.
Change it at runtime any time:
Log.MinimumLevel = LogLevel.Debug;Log.MinimumLevel = LogLevel.None; // nothing is ever writtenSince None (6) is higher than every real level, nothing clears the bar.
- Is the app/process dead or about to be? →
Critical - Did this operation fail (exception, request rejected)? →
Error - Did something odd happen but we coped? →
Warning - Is this the normal story of what the app is doing? →
Information - Is this only useful while debugging? →
Debug - Is this trace-level firehose detail? →
Trace
Thushar.Logging · a zero-dependency static logger for .NET
📦 NuGet · 💻 GitHub · 🐛 Issues · 📸 Instagram
dotnet add package Thushar.Logging
Getting around
Features
Using it
Under the hood