Symfony2 Monolog Settings for email and file logging

。_饼干妹妹 提交于 2019-12-03 04:22:21

The following is my production monolog config. This is confirmed working sending critical errors, whilst logging 'error' level and above to file. I've also split out the different channels to separate files. The other channels seem to produce errors far less than 'request', so it makes sense to split them out in production for me. Realise that's not your question, but hope it helps someone else; this can pared back to fit most requirements.

monolog:
  handlers:
    main:
        level: error
        type: stream
        path: "%kernel.logs_dir%/%kernel.environment%_remaining.log"
        channels: ["!doctrine", "!request", "!security"]
    request:
        type: fingers_crossed
        handler: requests
        excluded_404s:
            - ^/phpmyadmin
    requests:
        type:    group
        members: [request_critical, request_error]
    request_critical:
        level: critical
        type: stream
        path: "%kernel.logs_dir%/%kernel.environment%_request_critical.log"
        channels: [request]
    request_error:
        level: error
        type: stream
        path: "%kernel.logs_dir%/%kernel.environment%_request.log"
        channels: [request]
    doctrine:
        level: error
        type: stream
        path: "%kernel.logs_dir%/%kernel.environment%_doctrine.log"
        channels: [doctrine]
    security:
        level: error
        type: stream
        path: "%kernel.logs_dir%/%kernel.environment%_security.log"
        channels: [security]
    mail:
        type: fingers_crossed
        action_level: critical
        handler: buffered
    buffered:
        type: buffer
        handler: swift
    swift:
        type: swift_mailer
        from_email: aj.cerqueti@example.com
        to_email:   aj.cerqueti@example.com
        subject:    A critical error occurred
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!