2
我已经建立了独白我们的Symfony2项目发生时,他们通过电子邮件发送了严重的错误给我们。的Symfony2 +独白:不同的行动不同的误差水平
不过,我也想记录非关键性错误还,并通过电子邮件发送这些错误到不同的收件人。我很努力地在文档中看到它,但它看起来应该是可能的。我已经设置了如下配置:
parameters:
error_mail_sender: [email protected]
error_mail_recipients: [[email protected]]
critical_error_mail_recipients: [[email protected], [email protected]]
monolog:
handlers:
main_critical:
type: fingers_crossed
action_level: critical
handler: grouped_critical
bubble: false
main_error:
type: fingers_crossed
action_level: error
handler: grouped_error
grouped_critical:
type: group
members: [streamed, buffered_critical]
grouped_error:
type: group
members: [streamed, buffered_error]
streamed:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
buffered_critical:
type: buffer
handler: swift_critical
buffered_error:
type: buffer
handler: swift_error
swift_critical:
type: swift_mailer
from_email: %error_mail_sender%
to_email: %error_mail_recipients%
subject: Critical error occurred!
level: debug
swift_error:
type: swift_mailer
from_email: %error_mail_sender%
to_email: %critical_error_mail_recipients%
subject: Non-critical error occurred
level: debug
使用此设置,我们会收到严重错误,但不会收到非严重错误。
这一套了松散基础上的(接受的)这个问题的答案:How to include the severity of a log in the e-mail subject?。 (我将有上投了答案了它的工作对我!)
任何人都可以发现有什么不对呢?
谢谢!
对于其他人来说,这种配置将导致2封电子邮件被发送出现严重错误,每个处理程序一个。目前无法避免这种情况,正如Seldaek在这里向我解释的那样:https://github.com/Seldaek/monolog/issues/131#issuecomment-10884955 – lopsided
我更新了代码片段 – Seldaek