编辑config/web.php
首先log要开启

[file]

默认输出到runtime/logs/app.log
注意webserver或控制台用户要有写入该文件的权限
[database]

默认输出db组件对应的数据库下{{%log}}表
yii2根目录下运行下面命令生成对应的table schema
1 |
./yii migrate –migrationPath=@yii/log/migrations/ |
---|
注意config/console.php下也要有和web.php同样的配置,否则命令执行不成功。
还可以根据不同的环境配置不同的日志模式

正文完