Seldaek/monolog · error · InvalidArgumentException
Logger with the given name already exists
Error message
Logger with the given name already exists
What it means
Error "Logger with the given name already exists" thrown in Seldaek/monolog.
Source
Thrown at src/Monolog/Registry.php:60
*
* @var Logger[]
*/
private static array $loggers = [];
/**
* Adds new logging channel to the registry
*
* @param Logger $logger Instance of the logging channel
* @param string|null $name Name of the logging channel ($logger->getName() by default)
* @param bool $overwrite Overwrite instance in the registry if the given name already exists?
* @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists
*/
public static function addLogger(Logger $logger, ?string $name = null, bool $overwrite = false): void
{
$name = $name ?? $logger->getName();
if (isset(self::$loggers[$name]) && !$overwrite) {
throw new InvalidArgumentException('Logger with the given name already exists');
}
self::$loggers[$name] = $logger;
}
/**
* Checks if such logging channel exists by name or instance
*
* @param string|Logger $logger Name or logger instance
*/
public static function hasLogger($logger): bool
{
if ($logger instanceof Logger) {
$index = array_search($logger, self::$loggers, true);
return false !== $index;
}
View on GitHub (pinned to 57eb102834)
When it happens
Trigger: Thrown at src/Monolog/Registry.php:60 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17).
Data as JSON: /api/errors/d56ef851bf0b4652.
Report an issue: GitHub.