ASP.NET Core Interview Question #153

What are the standard log levels in ASP.NET Core?

Logging, Error Handling & Background Services Mid-Level Intermediate

Quick Interview Answer

ASP.NET Core logging defines Trace, Debug, Information, Warning, Error, Critical, and None levels.

Detailed Explanation

ASP.NET Core logging defines Trace, Debug, Information, Warning, Error, Critical, and None levels.

Trace is extremely detailed diagnostic information. Debug is useful during development and troubleshooting. Information records normal significant operations. Warning indicates an unexpected or potentially problematic situation. Error represents a failure in an operation, while Critical represents a severe failure requiring immediate attention.

None disables logging for a category. Production applications should configure levels carefully to balance diagnostic value, storage cost, performance, and security.

Code Example

_logger.LogTrace("Entering calculation");
_logger.LogDebug("Loaded {Count} products", count);
_logger.LogInformation("Order {OrderId} completed", orderId);
_logger.LogWarning("Retrying external service");
_logger.LogError(exception, "Order processing failed");
_logger.LogCritical(exception, "Critical system failure");