{"record":{"id":"69dd5822b96fec55","repo":"symfony/http-kernel","slug":"the-log-level-s-does-not-exist","errorCode":null,"errorMessage":"The log level \"%s\" does not exist.","messagePattern":"The log level \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Log/Logger.php","lineNumber":71,"sourceCode":"\n    /** @var resource|null */\n    private $handle;\n\n    /**\n     * @param string|resource|null $output\n     */\n    public function __construct(?string $minLevel = null, $output = null, ?callable $formatter = null, private readonly ?RequestStack $requestStack = null, bool $debug = false)\n    {\n        $minLevel ??= match ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'] ?? 0)) {\n            -1 => LogLevel::ERROR,\n            1 => LogLevel::NOTICE,\n            2 => LogLevel::INFO,\n            3 => LogLevel::DEBUG,\n            default => null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING,\n        };\n\n        if (!isset(self::LEVELS[$minLevel])) {\n            throw new InvalidArgumentException(\\sprintf('The log level \"%s\" does not exist.', $minLevel));\n        }\n\n        $this->minLevelIndex = self::LEVELS[$minLevel];\n        $this->formatter = null !== $formatter ? $formatter(...) : $this->format(...);\n        if ($output && false === $this->handle = \\is_string($output) ? @fopen($output, 'a') : $output) {\n            throw new InvalidArgumentException(\\sprintf('Unable to open \"%s\".', $output));\n        }\n        $this->debug = $debug;\n    }\n\n    public function enableDebug(): void\n    {\n        $this->debug = true;\n    }\n\n    public function log($level, $message, array $context = []): void\n    {\n        if (!isset(self::LEVELS[$level])) {","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Log/Logger.php#L53-L89","documentation":"Symfony's monolog-free Log\\Logger constructor validates that the given minimum level is a known PSR-3 level; if the string is not in its LEVELS map, it throws InvalidArgumentException immediately at construction time. This is fail-fast validation of a configuration value.","triggerScenarios":"Constructing Symfony\\Component\\HttpKernel\\Log\\Logger (or a service wired to it) with a $minLevel string that is not one of debug/info/notice/warning/error/critical/alert/emergency (or a valid verbosity constant mapping).","commonSituations":"Typo in a YAML/services log level config (e.g. 'warn' instead of 'warning'); uppercase levels like 'ERROR'; env var LOG_LEVEL containing an invalid value; custom factory passing verbosity strings directly.","solutions":["Use a valid PSR-3 LogLevel constant (e.g. LogLevel::WARNING)","Fix typos such as 'warn' -> 'warning' and lowercase the value (strtolower)","Sanitize env-derived levels before passing them to the constructor","Catch InvalidArgumentException at boot to surface bad config early"],"exampleFix":"// before\nnew Logger('warn', $output);\n\n// after\nuse Psr\\Log\\LogLevel;\nnew Logger(LogLevel::WARNING, $output);","handlingStrategy":"validation","validationCode":"$valid = ['debug','info','notice','warning','error','critical','alert','emergency'];\nif (!in_array(strtolower($minLevel), $valid, true)) {\n    throw new \\InvalidArgumentException(\"Invalid log level: $minLevel\");\n}","typeGuard":null,"tryCatchPattern":"try { $logger = new \\Symfony\\Component\\HttpKernel\\Log\\Logger($minLevel, $output); } catch (\\InvalidArgumentException $e) { /* fall back to default level */ $logger = new \\Symfony\\Component\\HttpKernel\\Log\\Logger('error', $output); }","preventionTips":["Always use Psr\\Log\\LogLevel::* constants instead of raw strings","Normalize env-derived levels with strtolower()","Validate log config at deploy/bootstrap time","Add a config schema test for log level values"],"tags":["logging","configuration","psr-3","invalid-argument"],"backgroundTag":"invalid-config-value","analyzedSha":"aa3a39d7286a62cdfea98f0e69c651a3da6e36cf","analyzedAt":"2026-09-13T18:03:36.509Z","contentChangedAt":"2026-09-13T18:03:36.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}