Coder Social home page Coder Social logo

Comments (4)

Seldaek avatar Seldaek commented on July 18, 2024

The problem seems to be bubble: false in the first handler, that means it'll stop propagating messages to other handlers.

Another note, I would remove the group and the streamed handler from grouped_critical, because it will already receive errors from grouped_error, resulting in duplicate entries in the log file.

So this should work:

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:      buffered_critical
        buffered_critical:
            type:    buffer
            handler: swift_critical
        swift_critical:
            type:       swift_mailer
            from_email: %error_mail_sender%
            to_email:   %error_mail_recipients%
            subject:    Critical error occurred!
            level:      debug

        main_error:
            type:         fingers_crossed
            action_level: error
            handler:      grouped_error
        grouped_error:
            type:    group
            members: [streamed, buffered_error]
        streamed:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
        buffered_error:
            type:    buffer
            handler: swift_error
        swift_error:
            type:       swift_mailer
            from_email: %error_mail_sender%
            to_email:   %critical_error_mail_recipients%
            subject:    Non-critical error occurred
            level:      debug

I reordered them to make it easier to see the two handler chains as well.

from monolog.

lopsided avatar lopsided commented on July 18, 2024

Thanks a lot for the reply! It is almost there now, however the only thing is that Critical errors are firing 2 emails, one from each handler. That's why I thought to add the bubble: false previously. I tried adding it back in but it doesn't seem to work

Is it possible to remove the second email for critical errors?

from monolog.

Seldaek avatar Seldaek commented on July 18, 2024

You can only filter down and not up, so you can't split the levels into =CRITICAL. That said, the problem seems to be that critical_error_mail_recipients contains the [email protected], but that one doesn't need to be there, since they'll already get a mail in case of simple errors. Just removing this should make sure everyone gets at most one mail.

from monolog.

lopsided avatar lopsided commented on July 18, 2024

Right yeah I thought that might be the case.

Thanks a lot for your help and explanations :)

from monolog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.