无为清净楼资源网 Design By www.qnjia.com
一:在配置文件的log组件中配置DbTarget
'log' => [ 'traceLevel' => YII_DEBUG "color: #ff0000">二:生成日志表在项目目录下执行如下命令生成日志表
php yii migrate --migrationPath=@yii/log/migrations/三:使用日志
在需要使用日志的地方使用
Yii::info()四:自定义DbTarget日志
1:首先创建一个自定义的日志表
(1)在项目目录下执行
php yii migrate/create create_test_log(2):在创建的migrate文件下编写创建数据库的迁移脚本
<"htmlcode">php yii migrate2:编写一个DbTarget类来继承yiilogDbTarget类
<"[$ip]"; } /** * @inheritdoc */ public function export() { if ($this->db->getTransaction()) { $this->db = clone $this->db; } $tableName = $this->db->quoteTableName($this->logTable); $sql = "INSERT INTO $tableName ([[level]], [[category]], [[prefix]], [[route]], [[method]], [[app]], [[module]], [[request]], [[status]], [[message]], [[request_at]], [[ip]]) VALUES (:level, :category, :prefix, :route, :method, :app, :module, :request, :status, :message, :request_at, :ip)"; $command = $this->db->createCommand($sql); $request = Yii::$app->getRequest(); list($route, $params) = $request->resolve(); $method = $request->getMethod(); $module = Yii::$app->controller->module->id; $route = str_replace("{$module}/", '', $route); foreach ($this->messages as $message) { list($text, $level, $category, $timestamp) = $message; $statusCode = 200; if (!is_string($text)) { if ($text instanceof \Throwable || $text instanceof \Exception) { $statusCode = $text instanceof HttpException "htmlcode">'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], 'test' => [ 'class' => 'app\components\DbTarget', 'logTable' => '{{%test_log}}', 'levels' => ['error', 'info', 'warning'], ], ], ],4:使用DbTarget日志
同样的使用Yii::info来记录日志
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 《叶倩文 真心真意过一生》[WAV+CUE][400MB]
- 潘越云.1985-世间女子(滚石25周年经典复刻版)【滚石】【WAV+CUE】
- 陈柏宇.2009-CANT.BE.HALF【SONY】【WAV+CUE】
- 李明依.1989-小女生【滚石】【WAV+CUE】
- 《李荣浩 新时代创作新人王》[WAV分轨][310MB]
- 《黑鸭子与马头琴 史上最动听草原音乐》[WAV+CUE][320MB]
- 《汽车发烧音乐精选CD18》[FLAC+CUE][7.1G]
- 郑希怡.2004-Perfect.Date【英皇娱乐】【FLAC分轨】
- 群星.1994-宝丽金超级孖宝2CD【宝丽金】【WAV+CUE】
- 林忆莲.2019-0(2023精装版)【环球】【WAV+CUE】
- Supper.Moment.2016-The.Moment【寰亚】【FLAC分轨】
- 范莉丝.1979-送郎一朵牵牛花(LP版)【大联机构】【WAV+CUE】
- 刘宇.2024-宇宙诗人【哔哟哔哟文化】【FLAC分轨】
- 《全景声白噪音》沉浸式大自然助眠 带你听自然的声音[mp3]
- 纯音入心系列纯音乐《古筝精选 十指弹一赏心曲一心奏出世人心》1CD[MP3][582MB]