Monolog

Learn how to enable Sentry's Symfony SDK to capture Monolog events.

When using Monolog you can configure a breadcrumb handler to capture Monolog messages as breadcrumbs and a handler that captures messages as events in Sentry. The breadcrumb handler will not send anything to Sentry directly, it only records breadcrumbs that will be attached to any event or exception sent to Sentry.

Copied
services:
  # Configure the breadcrumb handler as a service
  Sentry\Monolog\BreadcrumbHandler:
    arguments:
      - '@Sentry\State\HubInterface'
      - !php/const Monolog\Logger::INFO # Configures the level of messages to capture as breadcrumbs

monolog:
  handlers:
    # Register the breadcrumb handler as a Monolog handler
    sentry_breadcrumbs:
      type: service
      name: sentry_breadcrumbs
      id: Sentry\Monolog\BreadcrumbHandler
    # Register the handler as a Monolog handler to capture messages as events
    sentry:
      type: sentry
      level: !php/const Monolog\Logger::ERROR # Configures the level of messages to capture as events
      hub_id: Sentry\State\HubInterface
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").