Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to Setup to capture Monolog logs leading up to error as breadcrumbs #738

Unanswered
rijnhard asked this question in Q&A
Discussion options

The docs are quite unclear (atleast for me)
The goal is to log exceptions and all the logs leading up to that exception in a Sentry Issue (I am using monolog).

At the moment I'm not clear how the monolog Logging settings affects that or doest, both of my attempts have failed.

Attempt 1 - with monolog logger

sentry.yaml

sentry:
 dsn: '%env(SENTRY_DSN)%'
 # https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
 register_error_listener: false
 register_error_handler: false
options/
 options:
 environment: '%env(SENTRY_ENVIRONMENT)%'
 release: '%env(SENTRY_RELEASE)%'

monolog.yaml

monolog:
 handlers:
 main:
 type: fingers_crossed
 action_level: error
 handler: nested
 excluded_http_codes: [404, 405]
 buffer_size: 50
 channels: ["!event", "!doctrine", "!php"]
 nested:
 type: stream
 path: "%kernel.logs_dir%/%kernel.environment%.log"
 level: debug
 formatter: monolog.formatter.json
 console:
 type: console
 process_psr_3_messages: false
 channels: ["!event", "!doctrine"]
 sentry:
 type: sentry
 level: '%mk.sentry.log_level%'
 hub_id: Sentry\State\HubInterface
 channels: ["!deprecation"]

Attempt 2 - without monolog

sentry.yaml

sentry:
 dsn: '%env(SENTRY_DSN)%'
 # https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
 register_error_listener: true
 register_error_handler: true
options/
 options:
 environment: '%env(SENTRY_ENVIRONMENT)%'
 release: '%env(SENTRY_RELEASE)%'

monolog.yaml

monolog:
 handlers:
 main:
 type: fingers_crossed
 action_level: error
 handler: nested
 excluded_http_codes: [404, 405]
 buffer_size: 50
 channels: ["!event", "!doctrine", "!php"]
 nested:
 type: stream
 path: "%kernel.logs_dir%/%kernel.environment%.log"
 level: debug
 formatter: monolog.formatter.json
 console:
 type: console
 process_psr_3_messages: false
 channels: ["!event", "!doctrine"]
You must be logged in to vote

Replies: 1 comment

Comment options

I would like to know this too, currently all the logs are shown in the sentry as separate issues.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /