Symfony2 Monolog configure to use raven handler (Sentry)

杀马特。学长 韩版系。学妹 提交于 2019-12-10 13:47:28

问题


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?


回答1:


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! :)




回答2:


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


来源:https://stackoverflow.com/questions/21115076/symfony2-monolog-configure-to-use-raven-handler-sentry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!