PHP Error Logs in Heroku

微笑、不失礼 提交于 2019-11-29 16:36:54

问题


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.


回答1:


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.




回答2:


Try adding:

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

To the very top of your PHP page/app




回答3:


We had to add this to our buildpack in the bin/compile file:

cat >>boot.sh <<EOF
for var in \`env|cut -f1 -d=\`; do
  echo "PassEnv \$var" >> /app/apache/conf/httpd.conf;
done
touch /app/apache/logs/error_log
touch /app/apache/logs/access_log
touch /app/apache/logs/php_error.log
tail -F /app/apache/logs/error_log &
tail -F /app/apache/logs/access_log &
tail -F /app/apache/logs/php_error.log &
echo "Launching apache"
exec /app/apache/bin/httpd -DNO_DETACH
EOF

We left the php.ini and https.conf settings mostly as-is.




回答4:


That is not related to Heroku way of deploying, but to your PHP configuration. The error_log directive manages that.

The error_log directive defines the name of the file where script errors should be logged. The file should be writable by the web server's user.



来源:https://stackoverflow.com/questions/13772505/php-error-logs-in-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!