{"record":{"id":"6724d3dfaa3901bc","repo":"googleapis/mcp-toolbox","slug":"unable-to-initialize-http-log-w","errorCode":null,"errorMessage":"unable to initialize http log: %w","messagePattern":"unable to initialize http log: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/server/server.go","lineNumber":455,"sourceCode":"\t\treturn nil, err\n\t}\n\n\tctx, span := instrumentation.Tracer.Start(ctx, \"toolbox/server/init\")\n\tdefer span.End()\n\n\tl, err := util.LoggerFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// set up http serving\n\tr := chi.NewRouter()\n\tr.Use(middleware.Recoverer)\n\n\t// logging\n\tlogLevel, err := log.SeverityToLevel(cfg.LogLevel.String())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to initialize http log: %w\", err)\n\t}\n\n\tschema := *httplog.SchemaGCP\n\tschema.Level = cfg.LogLevel.String()\n\tschema.Concise(true)\n\thttpOpts := &httplog.Options{\n\t\tLevel:  logLevel,\n\t\tSchema: &schema,\n\t}\n\tlogger := l.SlogLogger()\n\tr.Use(httplog.RequestLogger(logger, httpOpts))\n\n\tsourcesMap, authServicesMap, embeddingModelsMap, toolsMap, promptsMap, groupsMap, err := InitializeConfigs(ctx, cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to initialize configs: %w\", err)\n\t}\n\n\taddr := net.JoinHostPort(cfg.Address, strconv.Itoa(cfg.Port))","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/server.go#L437-L473","documentation":"NewServer converts cfg.LogLevel (a severity enum) into a logging level via log.SeverityToLevel before wiring the HTTP request logger. If the configured log level string is not a recognized severity, the HTTP logger cannot be built and server startup aborts.","triggerScenarios":"Starting the server with an unrecognized --log-level / LogLevel value (e.g. a typo or a level name the severity parser does not accept) when calling NewServer via the run/runServe commands.","commonSituations":"Setting LOG_LEVEL env or CLI flag to values like \"verbose\" or \"warn2\", or programmatic ServerConfig construction with an invalid LogLevel string.","solutions":["Use a supported level: one of DEBUG/INFO/WARN/ERROR (case handled by SeverityToLevel) for --log-level.","Check the value of the log-level flag or environment variable for typos/whitespace.","In code, assign cfg.LogLevel from log.ParseSeverity-style helpers instead of raw strings."],"exampleFix":"// before\ntoolbox --log-level verbose serve ...\n\n// after\ntoolbox --log-level info serve ...","handlingStrategy":"validation","validationCode":"if _, err := log.SeverityToLevel(cfg.LogLevel.String()); err != nil {\n    return fmt.Errorf(\"invalid --log-level %q: use DEBUG|INFO|WARN|ERROR\", cfg.LogLevel.String())\n}","typeGuard":null,"tryCatchPattern":"if srv, err := server.NewServer(ctx, cfg); err != nil {\n    if strings.Contains(err.Error(), \"unable to initialize http log\") {\n        cfg.LogLevel = log.ParseSeverity(\"info\") // safe default\n        srv, err = server.NewServer(ctx, cfg)\n    }\n}","preventionTips":["Pin allowed log-level values in deployment manifests (enum validation).","Default to `info` when the flag is unset.","Shell-complete or whitelist the --log-level flag in launcher scripts."],"tags":["go","logging","configuration","cli"],"backgroundTag":"invalid-log-level","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}