Skip to content

Monolog Log Handler is using old constructor parameters #19177

Description

@nervster

SDK

PHP SDK

Description

Page: https://docs.sentry.io/platforms/php/logs/
SDK version: sentry/sentry 4.30

Problem
The PHP Logs docs show constructing the Monolog logs handler with a Hub (and level) argument

$handler = new \Sentry\Monolog\LogsHandler($hub, Level::Info);

This signature does not exist in sentry/sentry 4.30. LogsHandler does not accept a Hub in its constructor, so following the docs as written fails.

What works instead (4.30)

$log->pushHandler(new \Sentry\Monolog\LogsHandler(Level::Info));

The handler uses the current hub from the initialized SDK; no Hub argument is needed.

Request
Please update the Logs page to match the 4.x LogsHandler signature, or clarify which SDK version the current example targets.

Suggested Solution

$log->pushHandler(new \Sentry\Monolog\LogsHandler(Level::Info));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions