Skip to content

dneey/laravel-cloudwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AWS CloudWatch Logger for Laravel

Implementation of maxbanton AWS handler for monolog in Laravel.

Requirements

  • PHP ^7.2.0
  • Laravel ^6.0

Features

  • Includes incoming request parameters on every log.
  • Includes a requestId on every log to narrow down search results to a particular request's lifecycle.

Installation

Install the latest version with Composer by running

composer require dneey/laravel-cloudwatch

Basic Usage

Drop 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-region

That's it!

Log::info('You are now logging to cloudwatch');

Extra Configurations

  • You can configure your cloudwatch log group name and stream name in your .env file. If not set, the value of your APP_NAME will be used as the log group name and the value of your APP_NAME and APP_ENV will 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 14 days.
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_PARAMS to false in the .env file.
LOG_REQUEST_PARAMS=false
  • You can ignore any request parameter by adding a LOG_REQUESTS_EXCEPT entry 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"

Example

Log::info('Awesome! You are now logging to cloudwatch from Laravel.');

AWS

For AWS IAM and policy examples, kindly visit maxbanton AWS handler for monolog.

Packages

 
 
 

Contributors

Languages