0
votes

I work on two different projects based on symfony2.x and symfony 3.x. I want to setup both projects to send me an email for critical errors, but just log error-level errors.

The following setting works on symfony 2.8 but not on symfony3.

monolog:
handlers:
    main_critical:
        type:         fingers_crossed
        action_level: error
        excluded_404:
            - ^/
        handler:      grouped_critical
    grouped_critical:
        type:    group
        members: [streamed_critical, buffered_critical]
    streamed_critical:
        type:  stream
        path:  "%kernel.logs_dir%/%kernel.environment%_critical.log"
        level: critical
    buffered_critical:
        type:    buffer
        handler: swift_critical
    swift_critical:
        type:       swift_mailer
        from_email: "%error_mail_sender%"
        to_email:   "%critical_error_mail_recipients%"
        subject:    Critical error occurred!
        level:      critical
    main_error:
        type:         fingers_crossed
        action_level: error
        handler:      grouped_error
    grouped_error:
        type:    group
        members: [streamed_error]
    streamed_error:
        type:  stream
        path:  "%log_file_path%"
        level: error

The error is :

Fatal error: Uncaught Error: Maximum function nesting level of '256' reached, aborting! in /var/www/statistic/vendor/symfony/symfony/src/Symfony/Component/Debug/Exception/FatalErrorException.php on line 7

I am not sure what's wrong with this setting as it works for symfony 2.8 but not 3.x.

But when I remove this following block, then it works on symfony 3 project. But it will log only critical errors via email without following settings.

main_error:
    type:         fingers_crossed
    action_level: error
    handler:      grouped_error
grouped_error:
    type:    group
    members: [streamed_error]
streamed_error:
    type:  stream
    path:  "%log_file_path%"
    level: error

Any idea?

1
For general purposes, you should configure separate dev and prod environment debug settings. The dev settings should be expected to utilize XDebug and other debugging utilities, such as PHPUnit. Where the prod environment should not enable XDebug or include PHPUnit, as they are extra overhead that is not needed in a production environment. See Will enabling XDebug on a production server make PHP slower? - Will B.

1 Answers

0
votes

I think it's a problem of xdebug, please try to add into you php.ini or into you php configuration file this:

xdebug.max_nesting_level = 1000