yii錯(cuò)誤信息記錄在數(shù)據(jù)庫(kù)中,下面我們來(lái)看一下使用數(shù)據(jù)庫(kù)記錄錯(cuò)誤信息的方法。
命令行創(chuàng)建錯(cuò)誤日志表
1,配置文件:consoleconfigmain.php
'components' => [ 'log' => [ 'targets' => [ [ 'class' => 'yiilogFileTarget', 'levels' => ['error', 'warning'], ], [ 'class' => 'yiilogDbTarget', //使用數(shù)據(jù)庫(kù)記錄日志 'levels' => ['error', 'warning'], ] ], ] ],
2,cd 到項(xiàng)目根目錄,在common模塊配置好數(shù)據(jù)庫(kù)配置,執(zhí)行命令行創(chuàng)建表:
php?yii?migrate?–migrationPath=@yii/log/migrations/
修改配置文件:backendconfigmain.php
'components' => [ ... ... 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yiilogFileTarget', 'levels' => ['error', 'warning'], ], [ 'class' => 'yiilogDbTarget', //使用數(shù)據(jù)庫(kù)記錄日志 'levels' => ['error', 'warning'], ] ], ], ... ... ]
相關(guān)文章教程推薦:yii框架教程
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END