.NET Architecture & System Design Interview Question #147
What is structured logging?
Resilience, Rate Limiting, Health Checks & Observability Senior Advanced
Quick Interview Answer
Structured logging records events as named fields rather than only as preformatted text. This makes logs easier to query, aggregate, correlate, and analyze.
Detailed Explanation
Structured logging records events as named fields rather than only as preformatted text. This makes logs easier to query, aggregate, correlate, and analyze.
For example, storing OrderId as a property lets operators search across events reliably. Sensitive information such as passwords, tokens, and unnecessary personal data should not be logged.
Code Example
logger.LogInformation(
"Order {OrderId} completed for {CustomerId}",
order.Id,
order.CustomerId);
// OrderId and CustomerId are fields.