New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

hatchetaustralia/laravel-cloudwatch-logger

Laravel logger for AWS Clouldwatch Log service.
1,602
Install
composer require hatchetaustralia/laravel-cloudwatch-logger
Latest Version:v3.0.0
PHP:^7.3|^8.0
Laravel:7 · 8 · 9
License:MIT
Last Updated:Aug 15, 2022
Links: GitHub  ·  Packagist
Maintainer: hatchet

Laravel Logger for AWS CloudWatch

Laravel logger factory for AWS Cloudwatch Logs service.

Installation

You can install the package via composer:

composer require hatchetaustralia/laravel-cloudwatch-logger

Usage

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' => \Hatchet\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'),
        'batch_size' => env('CLOUDWATCH_LOG_BATCH_SIZE', 10000),
        'enabled' => env('CLOUDWATCH_ENABLED', true),
        'extra' => [
            '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',
]);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email support@hatchet.com.au instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

tarfin-labs/laravel-cloudwatch-logger

Laravel logger for AWS Clouldwatch Log service.

199,762 20
santiripper/watchtower

Watchtower is a Laravel wrapper for sending custom metrics to Amazon AWS CloudWa...

5,342 3
diephp/laravel-cloudwatch-logs

Laravel Adapter for AWS CloudWatch

1,409 0
sunergix/laravel-cloudwatch-logger

AWS CloudWatch logging driver for Laravel

1,013 0
aporat/laravel-cloudwatch-logger

A Laravel logging driver for AWS CloudWatch Logs integration

12,755 4

Version History

Version Released PHP Laravel License
v3.0.0 ^7.3|^8.0 ^7.0|^8.0|^9.0 MIT
v2.0.2 ^7.3 ^7.0|^8.0 MIT
v2.0.1 ^7.3 ^7.0|^8.0 MIT
v2.0.0 ^7.3 ^7.0|^8.0 MIT
v1.0.0 ^7.2 ^7.0 MIT