YII框架接入阿里云日志
1、依赖引入
进入项目根目录,执行 composer require --prefer-dist ranvk/yii2-aliyun-logtarget -vvv composer.json文件中会增加 "ranvk/yii2-aliyun-logtarget": "^18.3"
2、修改config配置文件
'components' => [ 'log' => [ 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning', 'trace', 'info'], ], [ 'levels' => ['error', 'warning', 'info'], 'class' => 'Ranvk\Yii2AliyunLogtarget\AliyunLogTarget', 'logstore' => 'test-test-com', 'topic' => YII_ENV, 'project' => 'test-webserver', 'accessKeyId' => 'LTAIOTest123456', 'accessKeySecret' => 'TestTest123456789', 'endpoint' => 'cn-shanghai.log.aliyuncs.com', //外网地址,内网地址为cn-shanghai-intranet.log.aliyuncs.com ], ], ],
3、使用
Yii::info('testtesttest')
参考:https://github.com/ranvk/yii2-aliyun-logtarget