Hi,
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
$yii=dirname(__FILE__).'/../yii/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
require_once($yii);
$DMBApp = Yii::createWebApplication($config);
$DMBApp->run();
//End time
$endtime = microtime();
$endtime = explode(" ", $endtime);
$endtime = $endtime[1] + $endtime[0];
Yii::getLogger()->flush();
Yii::log('Code execution time: '.round($endtime-$starttime, 5).' seconds', CLogger::LEVEL_INFO, 'application');
Yii::getLogger()->flush();