Monolog + E-Mail/Swift + Buffer = no E-Mail #154

Closed
raziel057 opened this Issue Jan 30, 2013 · 6 comments

Comments

Projects
None yet
3 participants
@raziel057

Hello,

After my Symfony project is allready finished I wanted to include some logging. With Monolog I quickly able to log into files, but I want some E-Mails if an error occurs.
I copy the config from the documentation, but I don't recieve any E-Mail.

    My config:
            mail:
                type: fingers_crossed
                action_level: error
                handler: buffered
            buffered:
                type: buffer
                handler: swift
            swift:
                type:       swift_mailer
                from_email: example@example.de
                to_email:   example@example.de
                subject:    An Error Occurred!
                level:      debug

If I change it to:

My config:
        mail:
            type: fingers_crossed
            action_level: error
            handler: swift
        swift:
            type:       swift_mailer
            from_email: example@example.de
            to_email:   example@example.de
            subject:    An Error Occurred!
            level:      debug

So disable the buffer. I get E-Mails, but to many (thats the reason for the buffer ...).

How can I activate the buffer and still get E-Mails? Is there any bug in the BufferHandler?

Here is my composer.json config:

    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.1.7",
        "doctrine/orm": ">=2.2.3,<2.4-dev",
        "doctrine/doctrine-bundle": "1.1.*",
        "twig/extensions": "1.0.*@dev",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.1.*",
        "symfony/monolog-bundle": "2.1.*",
        "sensio/distribution-bundle": "2.1.*",
        "sensio/framework-extra-bundle": "2.1.*",
        "sensio/generator-bundle": "2.1.*",
        "jms/security-extra-bundle": "1.2.*",
        "jms/di-extra-bundle": "1.1.*",
        "kriswallsmith/assetic": "1.1.*@dev",
        "friendsofsymfony/jsrouting-bundle": "1.0.*",
        "phpexcel/phpexcel": "dev-master",
        "genemu/form-bundle": "2.1.*",
        "whiteoctober/tcpdf-bundle": "dev-master",
        "avalanche123/imagine-bundle": "dev-master"
    },
@raziel057

This comment has been minimized.

Show comment
Hide comment
@raziel057

raziel057 Jan 30, 2013

I analysed and there is no problem in the BufferHandler and in the SwiftMailerHandler too. The send method of Swift_Mailer is called with a message and the Swift_Transport_Spool is used as transport. As result, the email is flag as sent, so all seems to be good. I need to check the trace on the smtp server to view the difference when using a buffer...

I analysed and there is no problem in the BufferHandler and in the SwiftMailerHandler too. The send method of Swift_Mailer is called with a message and the Swift_Transport_Spool is used as transport. As result, the email is flag as sent, so all seems to be good. I need to check the trace on the smtp server to view the difference when using a buffer...

@pborreli

This comment has been minimized.

Show comment
Hide comment
@pborreli

pborreli Jan 30, 2013

Contributor

I know it won't help you with the actual problem but why don't you want to keep write log to file + sens emails, this is the configuration I use and it works :

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      grouped
        grouped:
            type:    group
            members: [streamed, buffered]
        streamed:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
        buffered:
            type:    buffer
            handler: swift
        swift:
            type:       swift_mailer
            from_email: error@example.com
            to_email:   error@example.com
            subject:    An Error Occurred!
            level:      debug
Contributor

pborreli commented Jan 30, 2013

I know it won't help you with the actual problem but why don't you want to keep write log to file + sens emails, this is the configuration I use and it works :

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      grouped
        grouped:
            type:    group
            members: [streamed, buffered]
        streamed:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
        buffered:
            type:    buffer
            handler: swift
        swift:
            type:       swift_mailer
            from_email: error@example.com
            to_email:   error@example.com
            subject:    An Error Occurred!
            level:      debug
@raziel057

This comment has been minimized.

Show comment
Hide comment
@raziel057

raziel057 Jan 30, 2013

Yes I tried it too, it's the final configuration I want to use but for the moment I test with the minimal config (with buffer) to find the problem.

Yes I tried it too, it's the final configuration I want to use but for the moment I test with the minimal config (with buffer) to find the problem.

@raziel057

This comment has been minimized.

Show comment
Hide comment
@raziel057

raziel057 Jan 30, 2013

I found the problem. It comes from the fact I configured SwiftMailer with a spool type memory. If I remove it the email is sent correctly.

swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    port:      %mailer_port%
    username:  %mailer_user%
    password:  %mailer_password%
#    spool:     { type: memory }

It can be a problem of order in which the process are executed?

I found the problem. It comes from the fact I configured SwiftMailer with a spool type memory. If I remove it the email is sent correctly.

swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    port:      %mailer_port%
    username:  %mailer_user%
    password:  %mailer_password%
#    spool:     { type: memory }

It can be a problem of order in which the process are executed?

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Jan 30, 2013

Owner

This is a duplicate of symfony/symfony-standard#425 - the memory spool is currently not flushed at the very end of the request.

Owner

Seldaek commented Jan 30, 2013

This is a duplicate of symfony/symfony-standard#425 - the memory spool is currently not flushed at the very end of the request.

@Seldaek Seldaek closed this Jan 30, 2013

@raziel057

This comment has been minimized.

Show comment
Hide comment
@raziel057

raziel057 Jan 30, 2013

Ok thanks for the link to the original ticket!

Ok thanks for the link to the original ticket!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment