Search code examples
symfonyherokuinternal-server-error

Symfony on Heroku produces 500 Internal server error but there isn't the message


As i say in the title, the app produces a 500 internal server error, but in the logs there isn't the error, so I don't know how to understand what is happening.

This is the log:

2015-11-30T16:31:50.881209+00:00 heroku[router]: at=info method=GET path="/" host=myapp.herokuapp.com request_id=52d75ec4-3345-4d3c-88e6-a5f08c366dc2 fwd="151.77.121.140" dyno=web.1 connect=0ms service=10ms status=500 bytes=765
2015-11-30T16:31:50.882326+00:00 app[web.1]: 10.76.13.112 - - [30/Nov/2015:16:31:50 +0000] "GET / HTTP/1.1" 500 495 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
2015-11-30T16:31:51.618891+00:00 app[web.1]: 10.76.13.112 - - [30/Nov/2015:16:31:51 +0000] "GET /favicon.ico HTTP/1.1" 200 5430 "https://myapp.herokuapp.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
2015-11-30T16:31:51.617820+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=myapp.herokuapp.com request_id=cf2ecf03-65ee-4213-8d52-a7eaaa24ac76 fwd="151.77.121.140" dyno=web.1 connect=0ms service=1ms status=200 bytes=5696

How can I know which kind of error is producing the app so I can fix it?


Solution

  • Solved. To see the errors produced by the application, Symfony has to be configured to be compatible with the ephemeral system that Heroku uses.

    So in config_prod.yml set the monolog to write to php://stderr:

    monolog:
        handlers:
            main:
                type:         fingers_crossed
                action_level: error
                handler:      nested
            nested:
                type:  stream
                # Required by Heroku ephemeral filesystem
                path:  "php://stderr"
                level: debug
            console:
                type:  console
    

    More info about how to configure logging for Symfony apps on Heroku can be found on their help pages.

    PS

    The error was a simple mispelling: wrote default/index.html.twig instead of Default/index.html.twig. Is a problem of capital letters and git commits. Very simple but so tedious and hard to find!