Question

I want to use sentry to evaluate possible errors, exceptions, etc.

I tried to use the KunstmaanSentryBundle and it's great to catch all kind of errors like undefined functions and so on, but I want to define my own Monolog channel with it's own handler, but unfortunately I haven't found documentation about it.

config.yml would be something like:

monolog:
  handlers:
    sentry:
        type:  stream
        level: error
        //Log to database parameter (raven for sentry)

Does anybody knows the right configuration?

Was it helpful?

Solution

This is part of config_prod.yml:

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      grouped_main

        sentry:
            type:  raven
            dsn:   'http://user:pass@url/1'
            level: notice

        # Groups
        grouped_main:
            type:    group
            members: [sentry, streamed_main]

        # Streams
        streamed_main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: error

Enjoy! :)

OTHER TIPS

Wanted to add this as a comment on the accepted answer, but not enough rep, so:

From \Symfony\Bundle\MonologBundle\DependencyInjection\Configuration :

"Possible handler types and related configurations (brackets indicate optional params):

  • raven:
    • dsn: connection string
    • client_id: Raven client custom service id (optional)
    • [level]: level name or int value, defaults to DEBUG
    • [bubble]: bool, defaults to true

"

Example config would be:

monolog:
    handlers:
        sentry:
            type: raven
            dsn: '%sentry_api_key%'
            client_id: 'your.raven.client.custom.service.id'
            level: notice
            bubble: false
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top