Laravel logger factory for AWS Cloudwatch Logs service.
You can install the package via composer:
composer require tarfin-labs/laravel-cloudwatch-logger
Config parameters for logging are defined at config/logging.php
.
You need to add new channel as cloudwatch
and copy params inside config/config.php
into it.
'channels' => [
...
'cloudwatch' => [
'driver' => 'custom',
'via' => \TarfinLabs\LaravelCloudWatchLogger\LaravelCloudWatchLoggerFactory::class,
'aws' => [
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'version' => 'latest',
'credentials' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
],
],
'name' => env('CLOUDWATCH_LOG_NAME', ''),
'group' => env('CLOUDWATCH_LOG_GROUP_NAME', env('APP_NAME') . '-' . env('APP_ENV')),
'stream' => env('CLOUDWATCH_LOG_STREAM', 'default'),
'retention' => env('CLOUDWATCH_LOG_RETENTION', 7),
'level' => env('CLOUDWATCH_LOG_LEVEL', 'error'),
'extra' => [ // In case there's extra information to be logged
'env' => env('APP_ENV'),
'php' => PHP_VERSION,
'laravel' => app()->version(),
],
],
],
Change the log channel inside .env
file with cloudwatch
.
LOG_CHANNEL=cloudwatch
You can use Laravel's default Log
class to send your logs to CloudWatch.
\Illuminate\Support\Facades\Log::info('user logged in successfully', [
'id' => 1,
'username' => 'JohnDoe',
'ip' => '127.0.0.1',
]);
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.