{"record":{"id":"d56ef851bf0b4652","repo":"Seldaek/monolog","slug":"logger-with-the-given-name-already-exists","errorCode":null,"errorMessage":"Logger with the given name already exists","messagePattern":"Logger with the given name already exists","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Registry.php","lineNumber":60,"sourceCode":"     *\n     * @var Logger[]\n     */\n    private static array $loggers = [];\n\n    /**\n     * Adds new logging channel to the registry\n     *\n     * @param  Logger                    $logger    Instance of the logging channel\n     * @param  string|null               $name      Name of the logging channel ($logger->getName() by default)\n     * @param  bool                      $overwrite Overwrite instance in the registry if the given name already exists?\n     * @throws \\InvalidArgumentException If $overwrite set to false and named Logger instance already exists\n     */\n    public static function addLogger(Logger $logger, ?string $name = null, bool $overwrite = false): void\n    {\n        $name = $name ?? $logger->getName();\n\n        if (isset(self::$loggers[$name]) && !$overwrite) {\n            throw new InvalidArgumentException('Logger with the given name already exists');\n        }\n\n        self::$loggers[$name] = $logger;\n    }\n\n    /**\n     * Checks if such logging channel exists by name or instance\n     *\n     * @param string|Logger $logger Name or logger instance\n     */\n    public static function hasLogger($logger): bool\n    {\n        if ($logger instanceof Logger) {\n            $index = array_search($logger, self::$loggers, true);\n\n            return false !== $index;\n        }\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Registry.php#L42-L78","documentation":"Error \"Logger with the given name already exists\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Registry.php:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}