Forward Laravel Logs to Amazon Kinesis
Published on by Paul Redmond
The Laravel Monolog Kinesis package makes it simple to forward Laravel application logs to an AWS Kinesis stream.
Once you've configured a kinesis
service in the config/services.php
file, you can set up a logging channel in the config/logging.php
file:
'some_channel' => [ 'driver' => 'kinesis', 'stream' => 'some_stream_name', 'level' => 'info', // default level is debug],
If you have custom needs, you can set a different key, secret, and region at the channel level:
'some_channel' => [ 'driver' => 'kinesis', 'stream' => env('LOGGING_KINESIS_STREAM'), 'level' => env('LOG_LEVEL', 'debug'), 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),],
Under the hood, the package uses the AWS SDK (v3.x) Kinesis client to send records to the service after formatting logs via the package's custom formatter.
You can learn more about this package, get full installation instructions, and view the source code on GitHub.