Not able to log from index.php file


I am using Yii 1.1.3 and trying to log total php code execution time to a log file.

I use Yii::log() for this at the end of index.php file. But, it is not logging anything. If I use yii::log() anywhere in the controller/model/components, it works. But, if I use it in index.php file, its not working.

I tried using Yii::trace() and Yii::getLogger()->flush(). None of these worked.

Can someone please suggest, how to achieve this.

Below is my index.php file:

//Start time

$starttime = microtime();

$starttime = explode(" ", $starttime);

$starttime = $starttime[1] + $starttime[0];

// change the following paths if necessary



// remove the following lines when in production mode

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


$DMBApp = Yii::createWebApplication($config);


//End time

$endtime = microtime();

$endtime = explode(" ", $endtime);

$endtime = $endtime[1] + $endtime[0];


Yii::log('Code execution time: '.round($endtime-$starttime, 5).' seconds', CLogger::LEVEL_INFO, 'application');


That’s because Yii stops execution before “//End time” code is reached. Try using application events. This one should give you an idea: