Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Error Logs in Heroku

I have a PHP app deployed on Heroku, but I can't seem to locate the apache error log. Using the command $heroku logs I seem to get only the apache access logs. So a bunch of GET 200 OK etc, but no error information that is put into the error log locally, such as 'PHP Fatal error: blah blah'

Where do I access these error logs on Heroku, or how do I tell the app to write to Heroku's log like it does the local error log?

I feel like I'm overlooking something obvious but I can't seem to find a solution.

like image 823
nick Avatar asked Dec 07 '12 23:12

nick


People also ask

How do I see Heroku error logs?

You can view logs with the Heroku CLI, the dashboard, your logging add-on, or in your log drain. You can't view logs for apps in Shield spaces with Private Space Logging enabled. Retrieve logs from your log drain instead.

Does Heroku work with PHP?

Heroku recognizes an app as PHP by the existence of a composer. json file in the root directory. The composer. json file specifies the dependencies that should be installed with your application.

How do I debug my Heroku app?

If running heroku local does not help, run a remote shell: heroku run -a <your app name> /bin/bash , and there run npm start to see the logs and debug the issue on the Heroku server.

What are Heroku router logs?

Router logs are a special case of logs that exist somewhere between the application logs and the system logs and are not fully documented on Heroku's website at the time of writing. They carry information about HTTP routing within Heroku's Common Runtime, which manages dynos isolated in a single multi-tenant network.


2 Answers

After a lot of experimentation, it looks like you need to comment out error_log in php.ini and make sure log_errors = on .. this should output your errors to stderr where the heroku logplex can pick up the stream, then monitor with heroku logs --tail .. I launched a heroku facebook app and looked at their phpinfo() and copied the setup.

like image 94
bonez Avatar answered Oct 27 '22 05:10

bonez


Try adding:

error_reporting(E_ALL);
ini_set("display_errors", 1);

To the very top of your PHP page/app

like image 33
joshbirk Avatar answered Oct 27 '22 04:10

joshbirk