['yii\db\*','app\models\*']," ;Finally test it."/> ['yii\db\*','app\models\*']," ;Finally test it.">

Home  >  Article  >  PHP Framework  >  Where does yii add sql logging configuration information?

Where does yii add sql logging configuration information?

藏色散人
藏色散人Original
2020-07-20 09:07:553744browse

Yii method to add sql log information: first find and open the "config/web.php" file; then add the configuration as "'categories'=>['yii\db\*','app\ models\*'],"; just test it at the end.

Where does yii add sql logging configuration information?

When using the Yii2 framework, the problem of no sql logging often occurs. It is also unrealistic to print SQL statements sentence by sentence in the code. So it needs to be documented.

Recommended: "yii Tutorial"

Add the following configuration to the log configuration in config/web.php

                [                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning','info'],
                    'logVars'=>[],                    //表示以yii\db\或者app\models\开头的分类都会写入这个文件
                    'categories'=>['yii\db\*','app\models\*'],                    //表示写入到文件
                    'logFile'=>'@runtime/../runtime/logs/YIISQL_'.date('y_m_d').'.log',
                ],

Test it , the effect appears.

Detailed record information

 

The above is the detailed content of Where does yii add sql logging configuration information?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what does yii stand forNext article:what does yii stand for