{"record":{"id":"802f70654fe0c6ce","repo":"jaegertracing/jaeger","slug":"cannot-create-logger-w","errorCode":null,"errorMessage":"cannot create logger: %w","messagePattern":"cannot create logger: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/flags/service.go","lineNumber":73,"sourceCode":"\tAddConfigFileFlag(flagSet)\n\tAddLoggingFlags(flagSet)\n\tmetricsbuilder.AddFlags(flagSet)\n\ts.Admin.AddFlags(flagSet)\n\tfeaturegate.GlobalRegistry().RegisterFlags(flagSet)\n}\n\n// Start bootstraps the service and starts the admin server.\nfunc (s *Service) Start(v *viper.Viper) error {\n\tif err := TryLoadConfigFile(v); err != nil {\n\t\treturn fmt.Errorf(\"cannot load config file: %w\", err)\n\t}\n\n\tsFlags := new(SharedFlags).InitFromViper(v)\n\tnewProdConfig := zap.NewProductionConfig()\n\tnewProdConfig.Sampling = nil\n\tlogger, err := sFlags.NewLogger(newProdConfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot create logger: %w\", err)\n\t}\n\ts.Logger = logger\n\tgrpclog.SetLoggerV2(zapgrpc.NewLogger(\n\t\tlogger.WithOptions(\n\t\t\tzap.AddCallerSkip(5), // ensure the actual caller:lineNo is shown\n\t\t),\n\t))\n\n\tmetricsBuilder := new(metricsbuilder.Builder).InitFromViper(v)\n\tmetricsFactory, err := metricsBuilder.CreateMetricsFactory(\"\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot create metrics factory: %w\", err)\n\t}\n\ts.MetricsFactory = metricsFactory\n\n\tif err = s.Admin.initFromViper(v, s.Logger); err != nil {\n\t\treturn fmt.Errorf(\"cannot initialize admin server: %w\", err)\n\t}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/internal/flags/service.go#L55-L91","documentation":"After loading config and flags, Service.Start builds the zap logger via sFlags.NewLogger; a failure there (invalid log level/encoding values, bad zap config) is wrapped as \"cannot create logger\". Since logging is required for everything else, the service exits at boot.","triggerScenarios":"Passing --log-level with an unparseable value or --log-encoding set to something other than json/console that zap's config conversion rejects, making SharedFlags.NewLogger return an error.","commonSituations":"Typo like --log-encoding=text (valid values: json, console); invalid zap level string; a config file supplying a malformed logging section applied through InitFromViper.","solutions":["Check the wrapped cause for which logger option was rejected.","Use --log-encoding=json or console only; --log-level=debug|info|warn|error.","Inspect the logging section of the config file for invalid values.","Run with defaults (omit logging flags) to confirm flags are the cause."],"exampleFix":"// before\n--log-encoding=text\n// after\n--log-encoding=console","handlingStrategy":"validation","validationCode":"level := v.GetString(\"log-level\")\nif level != \"\" {\n    if _, err := zapcore.ParseLevel(level); err != nil {\n        return fmt.Errorf(\"invalid --log-level %q\", level)\n    }\n}\nenc := v.GetString(\"log-encoding\")\nif enc != \"\" && enc != \"json\" && enc != \"console\" {\n    return fmt.Errorf(\"invalid --log-encoding %q\", enc)\n}","typeGuard":null,"tryCatchPattern":"if err := svc.Start(v); err != nil {\n    if strings.Contains(err.Error(), \"cannot create logger\") {\n        // fix --log-level / --log-encoding values\n    }\n    return err\n}","preventionTips":["Use only json or console for --log-encoding.","Use standard level names (debug, info, warn, error) for --log-level.","Keep the config file's logging section schema-valid.","Smoke-test service startup with default logging flags."],"tags":["logging","zap","config"],"backgroundTag":"logger-init-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}