how to get php errors to show on syslog

风流意气都作罢 提交于 2019-12-05 02:03:34

There are two issues to consider:

First, PHP CLI uses a different php.ini than the version of PHP that runs via Apache. Make sure you are editing the error_log in the CLI version.

Second, make sure your log file is writable by the user that runs cron. Usually the logfile is not writable by your user account, so you may need to edit permissions.

I have this in my /etc/php5/cli/php.ini file (I use Debian; I'm assuming its the same for whatever you are using) and it writes out all cron errors to /var/log/messages:

error_reporting  =  E_ALL & ~E_NOTICE
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 0
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
error_log = syslog

Try error_log = syslog in your php.ini.

On Ubuntu 16.04, the /dev/log is owned by group mysyslog (as defined by systemd). So for apache2/php to be able to write into syslog, you must add user www-data to group mysyslog: addgroup www-data mysyslog

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