It is important to note that errors occurring in PHP script execution via browser are registered without any problem in the file: /var/log/apache2/error.log
.
The problem only happens when scripts are executed via the command line.
The sequence I performed is as follows:
1 - Clear Apache error log file:
root@debian:/# echo > /var/log/apache2/error.log
root@debian:/#
2 - Test whether the Apache log file has actually been cleaned:
root@debian:/# cat /var/log/apache2/error.log
root@debian:/#
Ok - The file is empty.
3 - Execution of a PHP script via the command line:
root@debian:/#php script.php
PHP Fatal error: Call to a member function setWhere() on null in /var/www/html/script.php on line 38
root@debian:/#
4 - Query the Apache log file:
root@debian:/# cat /var/log/apache2/error.log
root@debian:/#
The problem: The log file is still empty.
My question: Why do errors in PHP scripts run via the command line not appear (or are not appearing) in the apache error log? How can I log these errors in the file ( /var/log/apache2/error.log
)?
Thanks in advance for your help!