命令行创建错误日志表
1,配置文件:console\config\main.php
'components' => [ 'log' => [ 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], [ 'class' => 'yii\log\DbTarget', //使用数据库记录日志 'levels' => ['error', 'warning'], ] ], ]],
2,cd 到项目根目录,在common模块配置好数据库配置,执行命令行创建表:
php yii migrate --migrationPath=@yii/log/migrations/
修改配置文件:backend\config\main.php
'components' => [ ... ... 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], [ 'class' => 'yii\log\DbTarget', //使用数据库记录日志 'levels' => ['error', 'warning'], ] ], ], ... ...]