Here's a basic test script to show the issue I am having:
test1.php
<?php
error_log('hello');
?>
This works fine. Opening http://exmaple.com/test will log 'hello' into /var/log/apache2/error.log.
Now I have this, to run test.php in the background:
test2.php
<?php
shell_exec("/usr/bin/php /var/www/test.php > /dev/null 2>/dev/null &");
?>
I'm aware that the stderr is redirected to /dev/null in this example, but I have also tried it without > /dev/null 2>/dev/null & and still no logging occurs.
I did also try setting the error_log path in test.php using ini_set('error_log','/var/log/apache2/error.log');
Is there a way to get it to log correctly?
ini_set('error_log','/var/log/apache2/error.log');does refer to an apache log file. Which typically will not work as mentioned because of file permissions.