Seldaek/monolog · error · InvalidArgumentException

ElasticsearchHandler is only compatible with ElasticsearchFo

Error message

ElasticsearchHandler is only compatible with ElasticsearchFormatter

What it means

Error "ElasticsearchHandler is only compatible with ElasticsearchFormatter" thrown in Seldaek/monolog.

Source

Thrown at src/Monolog/Handler/ElasticsearchHandler.php:121

    /**
     * @inheritDoc
     */
    protected function write(LogRecord $record): void
    {
        $this->bulkSend([$record->formatted]);
    }

    /**
     * @inheritDoc
     */
    public function setFormatter(FormatterInterface $formatter): HandlerInterface
    {
        if ($formatter instanceof ElasticsearchFormatter) {
            return parent::setFormatter($formatter);
        }

        throw new InvalidArgumentException('ElasticsearchHandler is only compatible with ElasticsearchFormatter');
    }

    /**
     * Getter options
     *
     * @return mixed[]
     *
     * @phpstan-return Options
     */
    public function getOptions(): array
    {
        return $this->options;
    }

    /**
     * @inheritDoc
     */
    protected function getDefaultFormatter(): FormatterInterface

View on GitHub (pinned to 57eb102834)

When it happens

Trigger: Thrown at src/Monolog/Handler/ElasticsearchHandler.php:121 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/39a51cf9592010d8. Report an issue: GitHub.