Seldaek/monolog · error · RuntimeException

Composer package graylog2/gelf-php is required to use Monolo

Error message

Composer package graylog2/gelf-php is required to use Monolog's GelfMessageFormatter

What it means

Error "Composer package graylog2/gelf-php is required to use Monolog's GelfMessageFormatter" thrown in Seldaek/monolog.

Source

Thrown at src/Monolog/Formatter/GelfMessageFormatter.php:72

        return match ($level) {
            Level::Debug     => 7,
            Level::Info      => 6,
            Level::Notice    => 5,
            Level::Warning   => 4,
            Level::Error     => 3,
            Level::Critical  => 2,
            Level::Alert     => 1,
            Level::Emergency => 0,
        };
    }

    /**
     * @throws \RuntimeException
     */
    public function __construct(?string $systemName = null, ?string $extraPrefix = null, string $contextPrefix = 'ctxt_', ?int $maxLength = null)
    {
        if (!class_exists(Message::class)) {
            throw new \RuntimeException('Composer package graylog2/gelf-php is required to use Monolog\'s GelfMessageFormatter');
        }

        parent::__construct('U.u');

        $this->systemName = (null === $systemName || $systemName === '') ? (string) gethostname() : $systemName;

        $this->extraPrefix = null === $extraPrefix ? '' : $extraPrefix;
        $this->contextPrefix = $contextPrefix;
        $this->maxLength = null === $maxLength ? self::DEFAULT_MAX_LENGTH : $maxLength;
    }

    /**
     * @inheritDoc
     */
    public function format(LogRecord $record): Message
    {
        $context = $extra = [];
        if ($record->context !== []) {

View on GitHub (pinned to 57eb102834)

When it happens

Trigger: Thrown at src/Monolog/Formatter/GelfMessageFormatter.php:72 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/73ac9b273a09fbef. Report an issue: GitHub.