Aller au contenu

Log level (ARCH1005)

Ce contenu n’est pas encore disponible dans votre langue.

Key dotnet.logging.log-level · Severity info · Category logging

Using LogInformation for error conditions makes failures hard to track and warnings hard to filter. Choose the level that matches the context.

catch (Exception ex)
{
_logger.LogInformation(ex, "Database connection failed");
}
catch (Exception ex)
{
_logger.LogError(ex, "Database connection failed");
}

Use LogError for errors, LogWarning for warnings, and LogDebug for detailed traces so the level matches the context.