You are viewing revision #1 of this wiki article.
This is the latest version of this article.
Configuration files: ¶
/index.php
/protected/config/main.php
First add some definitions to index.php ¶
//debug
defined('YII_DEBUG') or define('YII_DEBUG',true );
//show profiler
defined('YII_DEBUG_SHOW_PROFILER') or define('YII_DEBUG_SHOW_PROFILER',true);
//enable profiling
defined('YII_DEBUG_PROFILING') or define('YII_DEBUG_PROFILING',true);
//trace level
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',0);
//execution time
defined('YII_DEBUG_DISPLAY_TIME') or define('YII_DEBUG_DISPLAY_TIME',false);
require_once($yii);
Yii::createWebApplication($config)->run();
if(YII_DEBUG_DISPLAY_TIME)
echo Yii::getLogger()->getExecutionTime();
Definition YII_DEBUG_SHOW_PROFILER enables and disables profiler log with default db query log.
Definition YII_DEBUG_PROFILING enable profiling (YII_DEBUG_SHOW_PROFILER must be true to enable profiling).
Definition YII_TRACE_LEVEL yii trace level from 0 to 4.
Definition YII_DEBUG_DISPLAY_TIME display execution time at the end of application.
Configuration file main.php ¶
return array(
...
'preload'=>array('log'),
...
'components'=>array(
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=dbname',
'emulatePrepare' => true,
'enableProfiling' =>YII_DEBUG_PROFILING,
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
),
....
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class' => 'CWebLogRoute',
'enabled' =>YII_DEBUG_SHOW_PROFILER,
'categories' => 'system.db.*',
),
),
),
),
);
Thats it :)
Additions
It worth adding
'enableParamLogging' => true,
and trying
'class'=>'CProfileLogRoute',
Also my dbprofiler extension can be handy.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.