Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 4 Production Mode ErrorHandling Pages Memory Exhausted

I set my project to prod mode in .env and everything aside from the custom error pages seem to work.

I have this as my 404 twig template:

{# templates/bundles/TwigBundle/Exception/error404.html.twig #}
{% include 'builder/layout/header.html.twig' with {'title': '404'} %}

<img src="{{ assets('img/not-found.jpeg') }}" class="img-responsive"
     id="error-not-found-img" />

<div class="http-error-msg-container">
    <h1>404! Page Not Found</h1>
    <p>Don't despair, go back to <a href="{{ path('dashboard') }}">Home</a> and try again.</p>
</div>

{% include 'builder/layout/footer.html.twig' %}

and going to a non-existant page (say /dashboard/giorgoirdjfisejf) returns a blank page. So I added this to my index.php file:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);

to show the errors and I got this:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/solomon/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /var/www/solomon/vendor/symfony/debug/Exception/OutOfMemoryException.php on line 1

I'm not quite sure why this causes an error and unable to debug. var/log/prod.log doesn't show anything, how do I resolve or better yet, how do I debug?

update

my prod/monolog.yaml file

monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: nested
            excluded_404s:
                # regex: exclude all 404 errors from the logs
                - ^/
        nested:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
        console:
            type:   console
            process_psr_3_messages: false
            channels: ["!event", "!doctrine"]

this was auto-generated and I've made no changes

like image 669
treyBake Avatar asked Jun 15 '18 12:06

treyBake


1 Answers

Check file permissions on symfony log files. It looks like monolog catches permission denied exception, tries to write it to log and catches same error again and again.

like image 145
Vadim Ashikhman Avatar answered Nov 15 '22 20:11

Vadim Ashikhman