My API (Laravel APP) is deployed on AWS Lambda. The goal is to log every Request/Response pair to Cloudwatch.
My approach was:
- define Cloudwatch channel inside config/logging.php as following:
'cloudwatch' => [
'name' => env('CLOUDWATCH_LOG_NAME', ''),
'region' => env('CLOUDWATCH_LOG_REGION', ''),
'credentials' => [
'key' => env('CLOUDWATCH_LOG_KEY', ''),
'secret' => env('CLOUDWATCH_LOG_SECRET', '')
],
'stream_name' => env('CLOUDWATCH_LOG_STREAM_NAME', 'laravel_app'),
'retention' => env('CLOUDWATCH_LOG_RETENTION_DAYS', 14),
'group_name' => env('CLOUDWATCH_LOG_GROUP_NAME', 'laravel_app'),
'version' => env('CLOUDWATCH_LOG_VERSION', 'latest'),
'formatter' => \Monolog\Formatter\JsonFormatter::class,
'disabled' => env('DISABLE_CLOUDWATCH_LOG', false),
],
Than create a API middelware and from there log values to this channel with:
Log::channel('cloudwatch')->info('Something happened!');
This change is not causing any problems, but I don't see any logs in the AWS CloudWatch.
Any ideas where is the piece that I am missing?