ASP.NET Core MVC Interview Question #135
What are the common ASP.NET Core logging levels?
Dependency Injection, Services, Error Handling, Logging & Performance Senior Advanced
Quick Interview Answer
The standard levels are Trace, Debug, Information, Warning, Error, and Critical. Trace and Debug are highly detailed; Information records normal significant operations; Warning represents unexpected or potentially problematic conditions; Error represents failures; and Critical represents severe failures requiring immediate attention.
Detailed Explanation
The standard levels are Trace, Debug, Information, Warning, Error, and Critical. Trace and Debug are highly detailed; Information records normal significant operations; Warning represents unexpected or potentially problematic conditions; Error represents failures; and Critical represents severe failures requiring immediate attention.
The configured minimum level determines which messages are emitted. Production systems should avoid excessive high-volume logging while retaining enough information for diagnosis.
Code Example
_logger.LogDebug("Loading product {ProductId}", id);
_logger.LogInformation("Product {ProductId} loaded", id);
_logger.LogWarning("Product {ProductId} not found", id);
_logger.LogError(ex, "Failed to load product {ProductId}", id);