How to debug 500 Error in Symfony 2

2019-02-05 20:09发布

问题:

I am struggling with Symfony 2 error reporting because I can't find out what really is happing when a 500 Error is triggered.

I have XDebug correctly installed, but it seems like Symfony rules everything.

The custom pages just says:

Oops! An Error Occurred

The server returned a "500 Internal Server Error".

Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

That's pretty much funny! Something is broken, but, the fact is that I need to fix my code, but can't know what or where it is the problem! And sure, If I send an email for the Symfony team will they be able to solve my problem once I not even know what to say them?

Some clue on what I am missing here?

回答1:

First, look at the logs in app/logs depending on your environment — dev.log for development, prod.log for production, etc.

If the code crashes before Symfony has a chance to run, check the logs of your web server — e.g. nginx.



回答2:

If you have a symfony flex project, it is also possible that you forgot to install monolog ;) Run:

composer req log


回答3:

An even better way to improve your Symfony debugging process is to have Monit monitor your Symfony and Apache logs for any errors and send you emails whenever something bad happens: http://intelligentbee.com/blog/2016/01/12/how-to-monitor-symfony-and-apache-logs-with-mmonit/