I have a basic php script that will write/log to a text document
<?php
$filename = 'php_log.log';
$somecontent = 'writing with fwrite!'.PHP_EOL;
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
error_log('logging with error_log!'.PHP_EOL,3,'php_log.log');
?>
From CLI, if i do php test.php
and check php_log.log, I see both writes.
But when I try php test.php &
, there is nothing written to php_log.log
Is there some php setting I am unaware of? Thanks!