Seldaek/monolog · error · InvalidArgumentException
$level is expected to be a string, int or {} instance
Error message
$level is expected to be a string, int or {} instance What it means
Error "$level is expected to be a string, int or {} instance" thrown in Seldaek/monolog.
Source
Thrown at src/Monolog/Logger.php:571
return $this->exceptionHandler;
}
/**
* Adds a log record at an arbitrary level.
*
* This method allows for compatibility with common interfaces.
*
* @param mixed $level The log level (a Monolog, PSR-3 or RFC 5424 level)
* @param string|Stringable $message The log message
* @param mixed[] $context The log context
*
* @phpstan-param Level|LogLevel::* $level
*/
public function log($level, string|\Stringable $message, array $context = []): void
{
if (!$level instanceof Level) {
if (!\is_string($level) && !\is_int($level)) {
throw new \InvalidArgumentException('$level is expected to be a string, int or '.Level::class.' instance');
}
if (isset(self::RFC_5424_LEVELS[$level])) {
$level = self::RFC_5424_LEVELS[$level];
}
$level = static::toMonologLevel($level);
}
$this->addRecord($level, (string) $message, $context);
}
/**
* Adds a log record at the DEBUG level.
*
* This method allows for compatibility with common interfaces.
*
* @param string|Stringable $message The log messageView on GitHub (pinned to 57eb102834)
When it happens
Trigger: Thrown at src/Monolog/Logger.php:571 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/c30b13ee59f4b0a0.
Report an issue: GitHub.