I tried to view application’s log before script complete.
I’ve read that CLogger class in Yii 1.1 has autoFlush property and flush() method to manage log flushing.
My script will be run for long time (contains large loop with network connection), so I need to see logged message before my script ends.
my approach (test case):
set_time_limit(0);
for($i = 1; $i <= 5; $i++) {
echo 'appending log at ' . date('Y-m-d H:i:s') . '<br />';
Yii::log('warning at ' . date('Y-m-d H:i:s'), 'warning');
$logger->flush();
sleep(5);
}
I monitored log file and see all logs still appears at once after script completed. What did I do wrong?
I also tried with autoFlush property:
$logger = Yii::getLogger();
$logger->autoFlush = 2;
Both method still output logs after script completed.