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.
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!