Reputation: 2507
For every error log sent by mail we get another extra email with 2 lines of smtp debug log messages.
symfony new --demo
)3.7.0
5.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: '[email protected]'
to_email: '[email protected]'
subject: 'An Error Occurred! %%message%%'
level: debug
Monolog sends error messages as expected, but every mail is followed by a second one with this content:
[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 [] []
dev
or test
environmentstest: true
in config/framework.yaml
Any ideas how to get rid of this extra email in production mode?
PS: There's also an open issue in the Symfony MonologBundle.
Upvotes: 12
Views: 1593
Reputation: 2507
As mentioned in the linked GitHub issue by @raziel057, a workaround would be to exclude the "mailer" channel.
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
Upvotes: 6