dotnet/aspnetcore · error · Error

Unknown log level

Error message

Unknown log level: ${name}

What it means

Thrown by parseLogLevel in HubConnectionBuilder when the string passed to `configureLogging` does not case-insensitively match any key in LogLevelNameMapping (trace/debug/information/warning/error/critical/none). The builder accepts either a LogLevel enum value or one of these canonical strings; an unrecognized string is rejected.

Solutions

  1. Use one of: trace, debug, information, warning, error, critical, none (case-insensitive).
  2. Prefer the LogLevel enum constant (`LogLevel.Information`) to avoid typos.
  3. If loading the level from config, validate against the allowed set.

Example fix

// before
.configureLogging("info")
// after
.configureLogging("information")
// or
import { LogLevel } from "@microsoft/signalr";
.configureLogging(LogLevel.Information)
Defensive patterns

Strategy: validation

Validate before calling

import { LogLevel } from "@microsoft/signalr";
const ALLOWED = ["trace","debug","information","warning","error","critical","none"];
function parseSafe(name: string): LogLevel | undefined {
  const n = name.toLowerCase();
  return ALLOWED.includes(n) ? (LogLevel as any)[n[0].toUpperCase()+n.slice(1)] : undefined;
}

Type guard

function isLogLevelName(name: string): boolean {
  return ["trace","debug","information","warning","error","critical","none"].includes(name.toLowerCase());
}

Prevention

When it happens

Trigger: Calling `.configureLogging("warn")`, `"info"`, `"verbose"`, `"DEBUG"` (only the canonical names are mapped — though lower-casing handles case, the canonical name set is fixed), or any typo of a supported level.

Common situations: Developers used to other loggers (winston, pino, log4j) passing `warn`/`info`/`fatal`, or passing a numeric-string like `"1"`.

Related errors


AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11). Data as JSON: /api/errors/d160b9317b389bb7. Report an issue: GitHub.

Appendix: source

Thrown at src/SignalR/clients/ts/signalr/src/HubConnectionBuilder.ts:38

    debug: LogLevel.Debug,
    info: LogLevel.Information,
    information: LogLevel.Information,
    warn: LogLevel.Warning,
    warning: LogLevel.Warning,
    error: LogLevel.Error,
    critical: LogLevel.Critical,
    none: LogLevel.None,
};

function parseLogLevel(name: string): LogLevel {
    // Case-insensitive matching via lower-casing
    // Yes, I know case-folding is a complicated problem in Unicode, but we only support
    // the ASCII strings defined in LogLevelNameMapping anyway, so it's fine -anurse.
    const mapping = LogLevelNameMapping[name.toLowerCase()];
    if (typeof mapping !== "undefined") {
        return mapping;
    } else {
        throw new Error(`Unknown log level: ${name}`);
    }
}

/** A builder for configuring {@link @microsoft/signalr.HubConnection} instances. */
export class HubConnectionBuilder {
    private _serverTimeoutInMilliseconds?: number;
    private _keepAliveIntervalInMilliseconds ?: number;

    /** @internal */
    public protocol?: IHubProtocol;
    /** @internal */
    public httpConnectionOptions?: IHttpConnectionOptions;
    /** @internal */
    public url?: string;
    /** @internal */
    public logger?: ILogger;

    /** If defined, this indicates the client should automatically attempt to reconnect if the connection is lost. */

View on GitHub (pinned to 3600ca084e)