vir*_*ize 11 php symfony monolog symfony-mailer
对于通过邮件发送的每个错误日志,我们都会收到另一封额外的电子邮件,其中包含 2 行 smtp 调试日志消息。
symfony new --demo)3.7.05.2.1// 5.2.9,5.3.0-RC1# config/packages/prod/monolog.yaml
monolog:
handlers:
main:
type: fingers_crossed
action_level: critical
handler: deduplicated
deduplicated:
type: deduplication
handler: symfony_mailer
symfony_mailer:
type: symfony_mailer
from_email: 'error@example.com'
to_email: 'error@example.com'
subject: 'An Error Occurred! %%message%%'
level: debug
Run Code Online (Sandbox Code Playgroud)
Monolog 按预期发送错误消息,但每封邮件后面都会跟着第二封包含以下内容的邮件:
[2021-05-26T10:49:47.683298+02:00] app.DEBUG: Email transport "Symfony\Component\Mailer\Transport\Smtp\SmtpTransport" stopping [] []
[2021-05-26T10:49:47.722980+02:00] app.DEBUG: Email transport "Symfony\Component\Mailer\Transport\Smtp\SmtpTransport" stopped [] []
Run Code Online (Sandbox Code Playgroud)
dev或test环境中没有额外的邮件test: true设置框架配置时没有额外的邮件config/framework.yaml有什么想法如何在生产模式下摆脱这个额外的电子邮件吗?
正如@raziel057在链接的 GitHub 问题中提到的,解决方法是排除“mailer”通道。
https://github.com/symfony/monolog-bundle/issues/405#issuecomment-1069040234
monolog:
handlers:
main:
type: fingers_crossed
action_level: critical
handler: grouped
channels: ["!mailer"]
grouped:
type: group
members: [streamed, deduplicated]
streamed:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
deduplicated:
type: deduplication
handler: symfony_mailer
symfony_mailer:
type: symfony_mailer
from_email: "%mailer_app_sender%"
to_email: "%mailer_team_receiver%"
subject: "An Error Occurred!"
level: debug
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1294 次 |
| 最近记录: |