{"record":{"id":"3a03774b20523048","repo":"crowdsecurity/crowdsec","slug":"unknown-log-mode-q","errorCode":null,"errorMessage":"unknown log_mode %q","messagePattern":"unknown log_mode %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/logging/standard.go","lineNumber":33,"sourceCode":"\n// SetupStandardLogger configures the global logger according to the\n// provided configuration. It applies the output destination, log format,\n// rotation policy, and log level used by all components that rely on the\n// default logrus instance (`logrus.StandardLogger()`).\nfunc SetupStandardLogger(cfg LogConfig, level logrus.Level, forceColors bool) error {\n\tvar logFormatter logrus.Formatter\n\n\tswitch cfg.GetMedia() {\n\tcase \"file\":\n\t\tlogrus.SetOutput(cfg.NewRotatingLogger(defLogFilename))\n\tcase \"syslog\":\n\t\tif err := setupSyslogDefault(); err != nil {\n\t\t\treturn err\n\t\t}\n\tcase \"stdout\":\n\t\t// noop\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown log_mode %q\", cfg.GetMedia())\n\t}\n\n\tlogrus.SetLevel(cmp.Or(level, defLogLevel))\n\n\tswitch cfg.GetFormat() {\n\tcase \"text\", \"\":\n\t\tlogFormatter = &logrus.TextFormatter{\n\t\t\tTimestampFormat: time.RFC3339,\n\t\t\tFullTimestamp:   true,\n\t\t\tForceColors:     forceColors,\n\t\t}\n\tcase \"json\":\n\t\tlogFormatter = &logrus.JSONFormatter{TimestampFormat: time.RFC3339}\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown log_format %q\", cfg.GetFormat())\n\t}\n\n\tlogrus.SetFormatter(logFormatter)","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/logging/standard.go#L15-L51","documentation":"SetupStandardLogger configures logrus from the logging config. The log_mode setting selects the output media (file, syslog, stdout); any value outside the recognized set hits the default branch and returns 'unknown log_mode %q'. It is raised from LoadConfig time, meaning crowdsec aborts startup on an invalid logging configuration.","triggerScenarios":"api.console/sapi or common logging config (csconfig) contains log_mode set to anything other than 'file', 'syslog', or 'stdout' — e.g. a typo like 'stout', a copied config from another product, or a hand-edited config.yaml.","commonSituations":"Hand-editing /etc/crowdsec/config.yaml or local dev.yaml; config templating writing a bad default; upgrading and an old non-standard value is no longer accepted.","solutions":["Set log_mode to one of: file, syslog, stdout","Check the exact quoted value in the error to spot the typo","Validate the whole logging section against current crowdsec docs after upgrades","Restart crowdsec to confirm startup succeeds"],"exampleFix":"// before (config.yaml)\ncommon:\n  log_mode: stoud\n// after\ncommon:\n  log_mode: stdout","handlingStrategy":"validation","validationCode":"# Pre-flight check of the config value:\n# shell: grep -A2 'log_mode' /etc/crowdsec/config.yaml\n# valid values: file | syslog | stdout","typeGuard":null,"tryCatchPattern":"// If configuring programmatically via csconfig:\nif err := logging.SetupStandardLogger(cfg); err != nil {\n    return fmt.Errorf(\"logging config invalid: %w\", err)\n}","preventionTips":["Copy log_mode values only from official docs, not other products","Use config templates/tests in IaC to assert log_mode ∈ {file, syslog, stdout}","Re-validate configs after crowdsec upgrades","Spot-check the quoted value in the error message for typos"],"tags":["crowdsec","logging","config"],"backgroundTag":"invalid-config-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}