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.yamlCopied
sentry:
options:
enable_logs: true
sentry:
options:
enable_logs: true
Then configure the Monolog handler for logs:
config/packages/monolog.yamlCopied
services:
Sentry\SentryBundle\Monolog\LogsHandler:
arguments:
- !php/const Monolog\Logger::WARNING
monolog:
handlers:
sentry_logs:
type: service
id: Sentry\SentryBundle\Monolog\LogsHandler
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.yamlCopied
services:
Sentry\Monolog\BreadcrumbHandler:
arguments:
$hub: '@Sentry\State\HubInterface'
$level: !php/const Monolog\Logger::INFO
services:
Sentry\Monolog\BreadcrumbHandler:
arguments:
$hub: '@Sentry\State\HubInterface'
$level: !php/const Monolog\Logger::INFO
monolog:
handlers:
sentry_breadcrumbs:
type: service
name: sentry_breadcrumbs
id: Sentry\Monolog\BreadcrumbHandler
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").
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").