Where can I find the MySQL Logs in Yii Framework

2019-07-16 06:48发布

问题:

I found this docs to enable the MySQL logging in the Yii Framework (my goal is it to improve the performance): http://www.yiiframework.com/wiki/235/configuring-cweblogroute-for-db-profiling/

Where can I the logs (after running the application)?

Thanks!

回答1:

If you use CWebLogRoute for logging then you can see your logs in your browser, just below content (like in example you provided).

You can also use CFileLogRoute, and Yii will create a application.log file in protected/runtime. In addition you can define fileName and filePath so you can log db messages in different log file.

'db'=>array(
    'connectionString' => 'mysql:host=localhost;dbname=name',
    'emulatePrepare' => true,
    'username' => 'username',
    'password' => 'password',
    'charset' => 'utf8',
    'enableParamLogging'=>true,
),
'log'=>array(
    'class'=>'CLogRouter',
    'routes'=>array(
        array(
            'class'=>'CFileLogRoute',
            'levels'=>'error, warning',
        ),
        array(
            'class'=>'CFileLogRoute',
            'levels'=>'trace',
            'categories'=>'system.db.CDbCommand',
            'fileName'=>'db.log',
        ),
    ),
),