Home > PHP Framework > YII > body text

Where does yii add sql logging configuration information?

藏色散人
Release: 2020-07-20 09:08:26
Original
3764 people have browsed it

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',
                ],
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template