如何阻止Monolog发送403错误?

时间:2018-06-15 06:57:42

标签: symfony symfony4 monolog

当我的应用程序发生错误时,我使用monolog通过电子邮件发送电子邮件,它工作得非常好,但我一直在接收电子邮件,拒绝访问"例外(403)。 在sf4.1中,new feature允许从日志记录中排除特定的http代码,所以我尝试了一下,但不幸的是它并没有改变。 仍会记录403个代码,我仍然会通过电子邮件发送给他们。

这是我的monolog.yaml

monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: nested
            excluded_http_codes: [403]
#            excluded_404s:
                # regex: exclude all 404 errors from the logs
#                - ^/
        nested:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
        console:
            type:   console
            process_psr_3_messages: false
            channels: ["!event", "!doctrine"]
        mail:
            type:         fingers_crossed
            # 500 errors are logged at the critical level
            action_level: critical
            # to also log 400 level errors (but not 404's):
            # action_level: error
            # excluded_404s:
            #     - ^/
            excluded_http_codes: [403]
            handler:      deduplicated
        deduplicated:
            type:    deduplication
            handler: swift
        swift:
            type:       swift_mailer
            from_email: '%email_sender%'
            to_email:   '%email_developer%'
            # or list of recipients
            # to_email:   ['dev1@example.com', 'dev2@example.com', ...]
            subject:    'An Error Occurred! %%message%%'
            level:      debug
            excluded_http_codes: [403]
            formatter:  monolog.formatter.html
            content_type: text/html

0 个答案:

没有答案