microsoft/aspire · error · ArgumentOutOfRangeException
Unsupported log level.
Error message
Unsupported log level.
What it means
LoggingExports.ParseLogLevel maps a level string to Microsoft.Extensions.Logging.LogLevel and throws ArgumentOutOfRangeException when the string matches no known level name and throwOnUnknown is true. Supported names are trace, debug, information/info, warning/warn, error, and critical.
Solutions
- Use one of the supported level strings: trace, debug, information, info, warning, warn, error, critical.
- Normalize nonstandard synonyms before calling (e.g., fatal -> critical, verbose -> debug).
- Trim the string if it may contain whitespace, or pass throwOnUnknown: false to fall back to Information instead of throwing.
Example fix
// before
Log("verbose", "message");
// after
Log("debug", "message"); Defensive patterns
Strategy: validation
Validate before calling
var allowed = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{ "trace", "debug", "information", "info", "warning", "warn", "error", "critical" };
if (!allowed.Contains(level))
{
level = level switch { "verbose" => "debug", "fatal" => "critical", _ => "information" };
} Type guard
bool IsKnownLogLevel(string s) => s.Trim().ToLowerInvariant() is "trace" or "debug" or "information" or "info" or "warning" or "warn" or "error" or "critical";
Try / catch
try
{
Log(level, message);
}
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "level")
{
Log("information", message); // safe fallback
} Prevention
- Keep a shared mapping from foreign level vocabularies (verbose/fatal) to Aspire's names.
- Trim and lowercase level strings sourced from config or scripts before calling.
When it happens
Trigger: Calling the Log ATS export with a level string like "verbose", "fatal", "critical-fatal", "WARN ", or any typo, while throwOnUnknown is enabled (as done by PipelineExports.ParseLogLevel).
Common situations: Level names taken from user scripts or config written in another library's vocabulary (e.g., "verbose", "fatal" from other logging frameworks); trailing whitespace or wrong casing is handled by the parser's ToLowerInvariant but exotic synonyms are not.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unsupported completion state.
- Address prefix must be a string or a parameter resource…
- Address prefix must be omitted, a string, or a parameter…
- All resources should be of the same kind when calling…
- apiPath is required when apiTarget is specified.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/4537ff4300e8709b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Ats/LoggingExports.cs:131
[AspireExport]
public static void CompleteLogByName(this ResourceLoggerService loggerService, string resourceName)
{
loggerService.Complete(resourceName);
}
internal static LogLevel ParseLogLevel(string level, bool throwOnUnknown = false)
{
ArgumentNullException.ThrowIfNull(level);
return level.ToLowerInvariant() switch
{
"trace" => LogLevel.Trace,
"debug" => LogLevel.Debug,
"information" or "info" => LogLevel.Information,
"warning" or "warn" => LogLevel.Warning,
"error" => LogLevel.Error,
"critical" => LogLevel.Critical,
_ when throwOnUnknown => throw new ArgumentOutOfRangeException(nameof(level), level, "Unsupported log level."),
_ => LogLevel.Information
};
}
}
View on GitHub (pinned to 25830f84bd)