log 

通过配置Web.config来完成 

1 数据库增加 ‘前缀_log’表

2 配置Web.config 

'bootstrap' => ['log'],
'components' =>[
'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0, //级别
            'targets' => [ 
                'file' => [  //使用文件存储日志
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
                'legcc' =>[  //自定义模式 [例如发邮件、微信等]
                    'class' => 'app\components\LegccLogTarget',
                    'levels' => ['error', 'warning'],
                    'categories' => [
                        'yii\db\*',
                        'yii\web\*',
                        'yii\base\*',
                    ],
                    'except' => [
                        'yii\web\HttpException:404',
                    ],
                    'logVars' => [],
                ],
                'db' =>[ //使用数据库存储日志
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['error', 'warning'],
                    'categories' => [
                        'yii\db\*',
                        'yii\web\*',
                        'yii\base\*',
                    ],
                    'except' => [
                        'yii\web\HttpException:404',
                    ],
                    'logVars' => ['_GET', '_POST',  '_COOKIE', '_SESSION', '_SERVER'],
                ],
            ],
        ],
]
View Code

相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案