This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

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

New topics about Symfony 2 should go here

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

by ball » Fri Sep 21, 2012 5:34 pm

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 occuerrs.
I copy the config from the documentation, but I don't recieve any E-Mail.
Code: Select all
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
Code: Select all
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?

mfg
Ben
ball
Junior Member
 
Posts: 3
Joined: Fri Sep 21, 2012 5:27 pm

Re: Monolog + E-Mail/Swift + Buffer = no E-Mail

by ball » Fri Oct 12, 2012 2:38 pm

Push...

Everywhere I look (google) I only find this config, but it doesn't work for me. Can anyone please try this config and confirm that it should work? Maybe there is a bug or something.
I would like to use this feature and it is really disapointing, that it doesn't work and I haven't andy idea how to fix it.
ball
Junior Member
 
Posts: 3
Joined: Fri Sep 21, 2012 5:27 pm

Re: Monolog + E-Mail/Swift + Buffer = no E-Mail

by bjo3rn » Fri Oct 12, 2012 3:57 pm

Hm, works as designed:

Code: Select all
monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: grouped
        grouped:
            type: group
            members: [stream,buffered]
        stream:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        buffered:
            type: buffer
            handler: swift
        swift:
            type: swift_mailer
            from_email: errors@some.tld
            to_email: errors@some.tld
            subject: Error on some.tld!
            level: debug


With
Code: Select all
$this->get('logger')->err('Something really bad happened!');

I receive one email. When I remove the buffer I receive around 20.
User avatar
bjo3rn
Faithful Member
 
Posts: 1245
Joined: Fri Jun 17, 2011 10:03 am
Location: Germany

Re: Monolog + E-Mail/Swift + Buffer = no E-Mail

by raziel057 » Wed Jan 30, 2013 9:53 am

Hello,

Same problem for me. I can send an email and the error notifier works if I don't use a buffer, but if I use the buffer like in the Symfony official documentation, none email is sent.

I use monolog v 1.2.1, monolog-bundle v 2.1.x-dev, swiftmailer v 4.2.2 and swiftmailer-bundle 2.1.x-dev

My composer.json:

"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
Junior Member
 
Posts: 4
Joined: Thu Jun 23, 2011 11:38 am

Re: Monolog + E-Mail/Swift + Buffer = no E-Mail

by raziel057 » Wed Jan 30, 2013 10:15 am

In fact, the problem is a known issue and is present when using a buffered swift_mailer Monolog handler with a memory spool.

As a workaround, to avoid any problems, comment the "spool: { type: memory }" in config.yml

See the following threads:
https://github.com/Seldaek/monolog/issues/154
https://github.com/symfony/symfony-standard/issues/425
raziel057
Junior Member
 
Posts: 4
Joined: Thu Jun 23, 2011 11:38 am