phperror-handlingsyslog

how to get php errors to show on syslog


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.


Solution

  • 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.