Reputation: 5662
I am not sure if this is the bug in yii or i am doing a wrong approach. I am creating a back-end process that runs without stop and logging is something that is crucial.
I created a console application. My logging works when I do this:
public function actionTest(){
Yii::log( "testing", 'error', 'worker.*');
return;
}
I am able to see "testing" logged into the file worker.log that is located in runtime folder>
However when I create an infinite loop, I don't see anything that is logged:
public function actionTest(){
while(1){
Yii::log( "testing", 'error', 'worker.*');
echo 'running';
usleep(5000000);
}
}
The worker.log file is empty.
Here is the configuration setting for worker.log in console.php:
array(
'class'=>'CFileLogRoute',
'categories' => 'worker.*',
'logFile' => 'worker.log'
)
Upvotes: 1
Views: 445
Reputation: 864
For performance reasons, by default Yii outputs log records at the end of the request OR when CLogger::autoFlash messages limit is reached IF CLogger::autoDump is set to true.
In your case this event never occurs. To fix it you have several options:
Upvotes: 2