{"record":{"id":"d160b9317b389bb7","repo":"dotnet/aspnetcore","slug":"unknown-log-level-name","errorCode":null,"errorMessage":"Unknown log level: ${name}","messagePattern":"Unknown log level: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/HubConnectionBuilder.ts","lineNumber":38,"sourceCode":"    debug: LogLevel.Debug,\n    info: LogLevel.Information,\n    information: LogLevel.Information,\n    warn: LogLevel.Warning,\n    warning: LogLevel.Warning,\n    error: LogLevel.Error,\n    critical: LogLevel.Critical,\n    none: LogLevel.None,\n};\n\nfunction parseLogLevel(name: string): LogLevel {\n    // Case-insensitive matching via lower-casing\n    // Yes, I know case-folding is a complicated problem in Unicode, but we only support\n    // the ASCII strings defined in LogLevelNameMapping anyway, so it's fine -anurse.\n    const mapping = LogLevelNameMapping[name.toLowerCase()];\n    if (typeof mapping !== \"undefined\") {\n        return mapping;\n    } else {\n        throw new Error(`Unknown log level: ${name}`);\n    }\n}\n\n/** A builder for configuring {@link @microsoft/signalr.HubConnection} instances. */\nexport class HubConnectionBuilder {\n    private _serverTimeoutInMilliseconds?: number;\n    private _keepAliveIntervalInMilliseconds ?: number;\n\n    /** @internal */\n    public protocol?: IHubProtocol;\n    /** @internal */\n    public httpConnectionOptions?: IHttpConnectionOptions;\n    /** @internal */\n    public url?: string;\n    /** @internal */\n    public logger?: ILogger;\n\n    /** If defined, this indicates the client should automatically attempt to reconnect if the connection is lost. */","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/ts/signalr/src/HubConnectionBuilder.ts#L20-L56","documentation":"Thrown at HubConnectionBuilder.ts:38 by parseLogLevel when a string passed to `configureLogging` does not match any key in LogLevelNameMapping (case-insensitive). Valid strings are trace, debug, info/information, warn/warning, error, critical, none.","triggerScenarios":"Calling `configureLogging('verbose')`, `configureLogging('INFO')` (this would actually work because matching is case-insensitive), `configureLogging('Informational')`, `configureLogging('all')`, or any string not in the mapping. The lookup at line 34 returns undefined and the function throws.","commonSituations":"Porting log level names from another library (log4j, pino, winston) that uses different names; typo like 'infomation'; env var with unexpected value; passing a numeric string like '3' instead of the enum.","solutions":["Use one of the supported strings: 'trace', 'debug', 'info'/'information', 'warn'/'warning', 'error', 'critical', 'none'.","If you have a LogLevel enum value, pass the enum directly: `configureLogging(LogLevel.Information)`.","Map your custom names to the supported set before calling configureLogging.","If loading from env, validate against a known list before passing."],"exampleFix":"// before\nbuilder.configureLogging(process.env.LOG_LEVEL); // e.g. 'verbose' -> throws\n\n// after\nconst ALLOWED = ['trace','debug','info','information','warn','warning','error','critical','none'];\nconst level = ALLOWED.includes(process.env.LOG_LEVEL?.toLowerCase())\n  ? process.env.LOG_LEVEL\n  : 'warning';\nbuilder.configureLogging(level);","handlingStrategy":"validation","validationCode":"const VALID = ['trace','debug','info','information','warn','warning','error','critical','none'];\nfunction safeLogLevel(name) {\n  const lower = String(name || '').toLowerCase();\n  if (!VALID.includes(lower)) throw new Error(`Unknown log level '${name}'. Valid: ${VALID.join(', ')}`);\n  return lower;\n}\nbuilder.configureLogging(safeLogLevel(process.env.LOG_LEVEL));","typeGuard":"function isKnownLogLevelName(name: string): boolean {\n  return ['trace','debug','info','information','warn','warning','error','critical','none'].includes(name.toLowerCase());\n}","tryCatchPattern":"try { builder.configureLogging(input); }\ncatch (e) {\n  if (/Unknown log level/.test(String(e))) {\n    builder.configureLogging('warning'); // safe default\n  } else throw e;\n}","preventionTips":["Validate user/env log level strings against the documented list before passing.","Prefer passing the LogLevel enum over strings.","Default to a known level when the input is missing or unrecognized."],"tags":["logging","configuration","validation","builder"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}