public function run($args) {
Yii::getLogger()->autoFlush = 1;
for (;<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />{
Yii::log('Something');
}
}
and
public function run($args) {
for (;<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />{
Yii::log('Something');
Yii::getLogger()->flush();
}
}
Alter the autoFlash property or call flush() manually after each log entry. This will trigger the onFlush event of your logger and send the collected log entries to your configured log routes.
EDIT: Sorry, didn’t read that Y!! suggested the same. Sure you’ve configured some log routes in your console config?
Aah, the problem seem to be in CLogRouter::collectLogs(). It calls collectLogs($logger,false) for all log routes. The false parameter tells the route not to process the log entries immediately. So the routes will collect the logs first and only log onEndRequest again. I think, there’s no simple way to circumvent this.
But you could try to write your custom LogRouter (extends CLogRouter) and override the collectLogs() method there. You’ll maybe have to flush the log route’s $log property, too, each time you process the logs.
Just found a problem, the logger didn’t work well if I use more than one logroute (CFileLogRoute and CDbLogRoute). And it didn’t work at all when I use only CDbLogRoute.
public function run($args) {
Yii::log('Something');
}
either with CFileLogRoute or CDbLogRoute or both,
but doesn’t work within the infinite loop.
If I use the CFileLogRoute with the custom CLogRouter, the logger works quite fine. But the CDbLogRoute alone doesn’t work not to mention when they’re both used.