aporat / laravel-cloudwatch-logger
A Laravel logging driver for AWS CloudWatch Logs integration
Fund package maintenance!
aporat
Requires
- php: ^8.4
- ext-json: *
- illuminate/log: ^10.0 || ^11.0 || ^12.0
- illuminate/support: ^10.0 || ^11.0 || ^12.0
- phpnexus/cwh: ^2.0 || ^3.0
Requires (Dev)
- laravel/pint: ^1.21
- mockery/mockery: ^1.6
- orchestra/testbench: ^8.0 || ^9.0 || ^10.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^11.0 || ^12.0
README
A Laravel logging driver for seamless integration with AWS CloudWatch Logs.
Features
- Custom Monolog channel for sending logs to CloudWatch.
- Configurable AWS credentials, log group, stream, retention, and batch size.
- Supports string-based, class-based, and callable custom log formatters.
- Fully compatible with Laravel's
Log
facade and channel system. - Simple, environment-based setup with a dedicated configuration file.
Requirements
- PHP:
^8.4
- Laravel:
^10.0
||^11.0
||^12.0
- AWS SDK: Provided via
phpnexus/cwh
Installation
-
Require the package via Composer:
composer require aporat/laravel-cloudwatch-logger
-
Publish the configuration file:
php artisan vendor:publish --provider="Aporat\CloudWatchLogger\CloudWatchLoggerServiceProvider" --tag="config"
This will create a
config/cloudwatch-logger.php
file in your application.
Configuration
Step 1: Add the CloudWatch Channel
Add the following channel definition to your config/logging.php
file's channels
array. This will use the configuration file you published in the previous step.
'channels' => [ // ... other channels 'cloudwatch' => require config_path('cloudwatch-logger.php'), ],