Can't logging in console application

Hi all

I tried to using log in my console app, and did not work, things like nothing happened

this is my console configure setting:






			'levels'=>'trace, info',







this configure works find at web application

I also googled and find from this forum, but also can’t find out why these happened

can someone help me out? thx!

Permission problem? This tip might help.

(I think an exception would be generated, though.)

Does the console application terminate correctly.

Perhaps Yii::app()->log->processLogs() or Yii::getLogger()->flush(true) may help.

Edit: hardly a permission problem since the file name is set to consoleApplication.log ;D


thx for reply :)

I tried Yii::app()->log->processLogs(), it works at the moment

but can’t let console application logging all the runtime, it should not be that, right?

what does your mean?

Maybe it is the problem, below are all my testing script.

I use testing script that only echo some text and also log something, but the same result, nothing happened…

here is my testing code:

class TestCommand extends CConsoleCommand{


	public function actionIndex(){

		echo 'test'.PHP_EOL;





php console.php test

my bootstrap "console.php":

// change the following paths if necessary



// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);



did I forgot anything?

ahh…I got something, I forgot a config:


after add this configure setting, my log file works fine.

but still can’t have a runtime logging, logging message always show in the end of execution.

I hope console logging can show on any time I want in my script, any idea?

I haven’t tried but you may want to have a closer look at this.

Also search the forum for existent info.


sorry I’m just a newbie so yesterday cannot reply more

I got this topic from the forum:

yeah, autoFlush is the key, and I found in 1.1.8, it has a more efficient way to have a real-time console logging architecture

here is my code, extend from CConsoleCommand:

class CLogConsoleCommand extends CConsoleCommand{


	public function run($args)


		Yii::getLogger()->autoFlush = 1;

		Yii::getLogger()->autoDump = true;




it works fine to me :)

thank you Tommy, hope this will help somewhere :)