错误处理-更改特定例外的收件人

时间:2018-11-28 12:42:29

标签: symfony symfony4 swiftmailer monolog

我使用Monolog / SwiftMailer组合将异常发送给特定的收件人。

我现在的目标是更改特定例外的收件人。
例如:

Throwable === \Exception -> send to test@test.de
Throwable === \MyOwnException -> send to myaddress@test.de

为此,我有我的独白配置:

monolog:
  channels:
    - 'custom'
  handlers:
    main:
      type: fingers_crossed
      action_level: error
      handler: grouped
    grouped:
      type:    group
      members: [streamed, deduplicated]
    deduplicated:
      type: deduplication
      time: 10
      handler: mail.group
    streamed:
      type:  stream
      path:  '%log.dir%/logfile.log'
      level: error
    mail.group:
      type: group
      members: [mail.default, mail.custom]
    mail.default:
      type: swift_mailer
      from_email: 'from@address'
      to_email:
        - 'to@address'
      subject: 'Subject'
      level: error
      formatter: monolog.formatter.html
      content_type: text/html
      channels:
        - '!custom'
    mail.custom:
      type: swift_mailer
      from_email: 'from@address'
      to_email:
        - 'to_custom@address'
      subject: 'Subject'
      level: error
      formatter: monolog.formatter.html
      content_type: text/html
      channels:
        - 'custom'

我也有自己的自定义ExceptionListener,我可以根据自己的习惯决定事物。
是否可以即时更改收件人或频道?

0 个答案:

没有答案