Monolog

Learn how to use Monolog with Sentry's Symfony SDK.

Monolog logs can be captured as Sentry Logs for better searchability and querying.

To enable this, set enable_logs to true in your Sentry configuration:

config/packages/sentry.yaml
Copied
sentry:
  options:
    enable_logs: true

Then configure the Monolog handler for logs:

config/packages/monolog.yaml
Copied
services:
  Sentry\SentryBundle\Monolog\LogsHandler:
    arguments:
      - !php/const Monolog\Logger::WARNING

monolog:
  handlers:
    sentry_logs:
      type: service
      id: Sentry\SentryBundle\Monolog\LogsHandler

You can control which log levels are sent to Sentry Logs by configuring the handler's minimum level in your services configuration.

When using Monolog you can configure a breadcrumb handler to capture Monolog messages as breadcrumbs. The breadcrumb handler does not send anything to Sentry directly. It records breadcrumbs that are attached to a later event or exception.

config/services.yaml
Copied
services:
  Sentry\Monolog\BreadcrumbHandler:
    arguments:
      $hub: '@Sentry\State\HubInterface'
      $level: !php/const Monolog\Logger::INFO
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").