olivefm/laravel-sls
最新稳定版本:v1.0.0
Composer 安装命令:
composer require olivefm/laravel-sls
包简介
Aliyun SLS Log For Laravel,lumen
README 文档
README
- lokielse/laravel-sls的分支,修改了一些代码支持lumen
Install
Via Composer
$ composer require olivefm/laravel-sls
Config
Add following service providers into your providers array in config/app.php
Lokielse\LaravelSLS\LaravelSLSServiceProvider::class
Copy sls.php to config folder
For Lumen
Add following code into in bootstrap/app.php
$app->configure("sls");
Replace Log alias in your config/app.php (Optional)
//'Log' => Illuminate\Support\Facades\Log::class, 'Log' => Lokielse\LaravelSLS\Facades\WriterFacade::class, 'SLSLog' => Lokielse\LaravelSLS\Facades\LogFacade::class,
Edit your .env file
ALIYUN_ACCESS_KEY_ID=... ALIYUN_ACCESS_KEY_SECRET=... # https://help.aliyun.com/document_detail/29008.html # 如杭州公网 cn-hangzhou.log.aliyuncs.com # 如杭州内网 cn-hangzhou-intranet.log.aliyuncs.com SLS_ENDPOINT=cn-hangzhou.log.aliyuncs.com SLS_PROJECT=test-project SLS_STORE=test-store
You should update SLS_ENDPOINT to internal endpoint in production mode
Usage
First create a project and store at Aliyun SLS Console
Then update SLS_ENDPOINT, SLS_PROJECT, SLS_STORE in .env
Push a test message to queue
Log::info('Test Message', ['foobar'=>'2003']); //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']) ]);
Security
Create RAM access control at Aliyun RAM Console
-
Create a custom policy such as
AliyunSLSFullAccessFoobar{ "Version": "1", "Statement": [ { "Action": "log:*", "Resource": [ "acs:log:*:*:project/test-project/logstore/test-store", ], "Effect": "Allow" } ] } -
Create a user for you app such as
foobar -
Assign the policy
AliyunSLSFullAccessFoobarto the userfoobar -
Create and get the
AccessKeyIdandAccessKeySecretfor userfoorbar -
update
QUEUE_SLS_ACCESS_KEYandQUEUE_SLS_ACCESS_SECRETin.env
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 69
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-10