wangyipinglove / lumen-alilog
阿里云SLS日志服务For Lumen
dev-master
2020-07-13 03:48 UTC
Requires
- php: ~7.0
- illuminate/support: 7.*
- lokielse/aliyun-open-api-sls: ^1.0.0
This package is auto-updated.
Last update: 2024-09-13 13:08:23 UTC
README
安装
通过Composer
$ composer require wangyiping/lumen-alilog
配置
将以下服务提供者添加到您的 bootstrap/app.php
中的 providers 数组中
$app->configure('sls'); $app->register(Wangyipinglove\LumenAliLog\Logging\SLSFormatter::class);
编辑您的 .env
文件
LOG_CHANNEL=sls ALI_LOGSTORE_ENDPOINT=xxxxxxxx ALI_LOGSTORE_ACCESS_KEY_ID=xxxxxxxx ALI_LOGSTORE_ACCESS_KEY_SECRET=xxxxxxxx ALI_LOGSTORE_PROJECT_NAME=my-project ALI_LOGSTORE_NAME=test-app
在生产模式下,您应该将 ALI_LOGSTORE_ENDPOINT
更新为 内部端点
运行 php artisan lumen-sls:publish-config
来发布配置(config/sls.php
)
如有需要,进行配置更改
用法
首先创建一个项目并在 阿里云SLS控制台 存储它
然后更新 .env
中的 ALI_LOGSTORE_ENDPOINT
、ALI_LOGSTORE_PROJECT_NAME
和 ALI_LOGSTORE_NAME
向队列推送一条测试消息
Log::info('Test Message', ['myname'=>'wangyiping']); //or you can use `app('sls')` app('sls')->putLogs([ 'type' => 'test', 'message' => json_encode(['This should use json_encode']) ]); //or you can use `SLSLog` directly SLSLog::putLogs([ 'type' => 'test', 'message' => json_encode(['This should use json_encode']) ]);