PHP code example of hatchetaustralia / laravel-cloudwatch-logger
1. Go to this page and download the library: Download hatchetaustralia/laravel-cloudwatch-logger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
hatchetaustralia / laravel-cloudwatch-logger example snippets
\Illuminate\Support\Facades\Log::info('user logged in successfully', [
'id' => 1,
'username' => 'JohnDoe',
'ip' => '127.0.0.1',
]);
php
'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(),
],
],
],
dotenv
LOG_CHANNEL=cloudwatch