I have a script which is scheduled to run on crontab. I noticed that I could not see php errors anywhere. I wanted to be able to see php errors logged on /var/log/syslog or some place else. I have tried configuring my php.ini to log the errors on /var/log/php-errors.log, checked permissions and restarted the apache service still no logs.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
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
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:Try
error_log = syslog
in your php.ini.