Implementation of maxbanton AWS handler for monolog in Laravel.
- PHP ^7.2.0
- Laravel ^6.0
- Includes incoming request parameters on every log.
- Includes a
requestIdon every log to narrow down search results to a particular request's lifecycle.
Install the latest version with Composer by running
composer require dneey/laravel-cloudwatchDrop this in your application's .env file with your correct AWS credentials.
LOG_CHANNEL=cloudwatch
AWS_ACCESS_KEY_ID=aws-key
AWS_SECRET_ACCESS_KEY=aws-secret
AWS_DEFAULT_REGION=aws-regionThat's it!
Log::info('You are now logging to cloudwatch');- You can configure your cloudwatch
log group nameandstream namein your .env file. If not set, the value of yourAPP_NAMEwill be used as the log group name and the value of yourAPP_NAMEandAPP_ENVwill be used as your log stream name.
AWS_CLOUD_WATCH_GROUP_NAME=project-name
AWS_CLOUD_WATCH_STREAM_NAME=project-name-env- Set log level eg. INFO,CRITICAL,DEBUG,API etc.
AWS_CLOUD_WATCH_LEVEL=INFO- Set log retention period cloudwatch in days. The default is
14days.
AWS_CLOUD_WATCH_RETENTION_DAYS=14- By default all request params will be logged except passwords and password confirmations. To change this, set
LOG_REQUEST_PARAMSto false in the .env file.
LOG_REQUEST_PARAMS=false- You can ignore any request parameter by adding a
LOG_REQUESTS_EXCEPTentry to your .env file. The value should contain a comma separated string of fields to exclude from your logs.
LOG_REQUESTS_EXCEPT="password, password_confirmation, image"Log::info('Awesome! You are now logging to cloudwatch from Laravel.');For AWS IAM and policy examples, kindly visit maxbanton AWS handler for monolog.