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.
Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
If the syslog is used, then all PHP errors will be sent directly to the default system log file—in Linux, this is typically /var/log/syslog.
syslog() generates a log message that will be distributed by the system logger. For information on setting up a user defined log handler, see the syslog. conf (5) Unix manual page. More information on the syslog facilities and option can be found in the man pages for syslog (3) on Unix machines.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With