Package Data | |
---|---|
Maintainer Username: | waisir |
Maintainer Contact: | lokielse@gmail.com (lokielse) |
Package Create Date: | 2016-07-22 |
Package Last Update: | 2019-03-07 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-18 03:06:30 |
Package Statistics | |
---|---|
Total Downloads: | 3,689 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 21 |
Total Watchers: | 4 |
Total Forks: | 13 |
Total Open Issues: | 0 |
Via Composer
$ composer require lokielse/laravel-sls
Add following service providers into your providers array in config/app.php
Lokielse\LaravelSLS\LaravelSLSServiceProvider::class
Publish sls.php
to config
folder
php artisan vendor:publish --provider="Lokielse\LaravelSLS\LaravelSLSServiceProvider"
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
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'])
]);
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 AliyunSLSFullAccessFoobar
to the user foobar
Create and get the AccessKeyId
and AccessKeySecret
for user foorbar
update QUEUE_SLS_ACCESS_KEY
and QUEUE_SLS_ACCESS_SECRET
in .env
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
The MIT License (MIT). Please see License File for more information.