Section 2 of 5 Logging libraries
Dimension by dimension
A. Code cleanliness & code pollution (boilerplate)
Traditional logging (Serilog / NLog) requires injecting ILogger<T> into every constructor. Methods need manual log calls at start, exit, and catch blocks — often 20–30% of a method body.
public Order ProcessOrder(OrderRequest req) {
_logger.LogInformation("Processing order for customer {Id}", req.CustomerId);
try {
var res = _db.Save(req);
_logger.LogInformation("Order processed successfully. Order ID: {Id}", res.Id);
return res;
} catch (Exception ex) {
_logger.LogError(ex, "Failed to process order for customer {Id}", req.CustomerId);
throw;
}
}ArgusLogs — zero pollution
Apply a single declarative [LogMethod] at class or method level. The post-build weaver injects boundary telemetry (parameters, exceptions, durations) automatically.
[LogMethod]
public Order ProcessOrder(OrderRequest req) {
return _db.Save(req); // Core logic stays 100% clean
}B. Logical context propagation (trace correlation)
- Traditional — Correlating an HTTP request with nested DB queries and API calls needs BeginScope or manual ThreadLocal / AsyncLocal tracking.
- ArgusLogs — Built-in ArgusLogsContext propagates correlation IDs, parent/child structure, and cross-thread async boundaries out of the box.
C. Database & outbound network interception
- Traditional — Requires separate third-party packages (EF interceptors, custom HttpMessageHandlers) plus custom formatting code.
- ArgusLogs — Native ArgusLogs.DatabaseTracker and ArgusLogs.NetworkTracker modules.
- Database — EF Core and raw ADO.NET / Dapper: SQL text, parameters, latency, caller context.
- Network — Outbound HttpClient via DiagnosticListener — no custom delegating handlers in app code.
D. Performance & memory allocation
- Traditional — Runtime template formatting and scope allocations can churn memory and pressure GC under high throughput.
- ArgusLogs — Compile-time interception injects static calls (no runtime reflection). Telemetry flushes asynchronously through an optimized LogManager background buffer.