Details

Language / Topic
csharpC#
Category
Libraries

Rules

balanced

Serilog

- Use structured log templates with named properties: `Log.Information("Order {OrderId} placed by {UserId}", orderId, userId)` — never use string interpolation (`$""`). Configure sinks in `Program.cs` with `WriteTo.Console()` and `WriteTo.File()`.

Serilog

- Use structured log templates with named properties: `Log.Information("Order {OrderId} placed by {UserId}", orderId, userId)` — never use string interpolation (`$""`). Configure sinks in `Program.cs` with `WriteTo.Console()` and `WriteTo.File()`.
- Use `LogContext.PushProperty()` for correlation IDs and request-scoped data. Use enrichers (`Enrich.FromLogContext()`, `Enrich.WithMachineName()`) for automatic context. Set minimum level per sink: verbose to file, warning to console. Use `Serilog.AspNetCore` with `UseSerilogRequestLogging()` for HTTP request logs. Implement `ILogger<T>` injection via Microsoft DI integration.