9

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

4
  • Its trying to log something big, so it crash and thats the reason why there is nothing in your prod.log. Try it on your local machine with memory_limit -1 and you could see what it is
    – Eakethet
    Commented Jun 15, 2018 at 12:06
  • What TYPE of handler? Commented Jun 15, 2018 at 12:07
  • in your config yaml for monolog, what type of log handler are you using? Commented Jun 15, 2018 at 12:25
  • Try adding buffer_size: 200 to the handler config Commented Jun 15, 2018 at 12:25

2 Answers 2

22

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.

1
  • forgot to actually check the error log, dankes this showed the actual error and I resolved it straight away :)
    – treyBake
    Commented Jun 15, 2018 at 12:37
0

In my case, the error message was almost identical, except the stack trace always pointed to line 171 in StreamHandler.php. The problem was that Composer was run on Windows and the resulting files were copied to a Linux system. This resulted in the incorrect directory separator being used and Symfony then tried to create /var/www/html/var\log/prod.log (contains backslash), which obviously fails.

So be sure to run Composer on the same OS on which you will be running the application later.

Not the answer you're looking for? Browse other questions tagged or ask your own question.