Download the PHP package sinemacula/laravel-log-cloudwatch without Composer

On this page you can find all versions of the php package sinemacula/laravel-log-cloudwatch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-log-cloudwatch

Laravel Log CloudWatch

[![Latest Stable Version](https://img.shields.io/packagist/v/sinemacula/laravel-log-cloudwatch.svg)](https://packagist.org/packages/sinemacula/laravel-log-cloudwatch) [![Build Status](https://github.com/sinemacula/laravel-log-cloudwatch/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/sinemacula/laravel-log-cloudwatch/actions/workflows/tests.yml) [![Quality Gates](https://github.com/sinemacula/laravel-log-cloudwatch/actions/workflows/quality-gates.yml/badge.svg?branch=master)](https://github.com/sinemacula/laravel-log-cloudwatch/actions/workflows/quality-gates.yml) [![Maintainability](https://qlty.sh/gh/sinemacula/projects/laravel-log-cloudwatch/maintainability.svg)](https://qlty.sh/gh/sinemacula/projects/laravel-log-cloudwatch) [![Code Coverage](https://qlty.sh/gh/sinemacula/projects/laravel-log-cloudwatch/coverage.svg)](https://qlty.sh/gh/sinemacula/projects/laravel-log-cloudwatch) [![Total Downloads](https://img.shields.io/packagist/dt/sinemacula/laravel-log-cloudwatch.svg)](https://packagist.org/packages/sinemacula/laravel-log-cloudwatch)

A CloudWatch Monolog log driver for Laravel. Registers a cloudwatch custom log channel that ships log records to AWS CloudWatch Logs via phpnexus/cwh, so application logs land in CloudWatch without any bespoke wiring.

The driver is registered automatically through Laravel's package auto-discovery; add a cloudwatch channel to your logging config (see below) to start shipping logs.

How It Works

The package registers a cloudwatch driver with Laravel's log manager through LogCloudWatchServiceProvider. When a channel configured with 'driver' => 'cloudwatch' is resolved, the driver builds a Monolog Logger backed by a single phpnexus/cwh CloudWatch handler, constructed from the channel's settings.

A few rules hold:

Installation

The service provider is auto-discovered.

Configuration

Add a cloudwatch channel to your config/logging.php:

This example relies on the AWS default credential provider chain (an IAM role or instance profile), which is the recommended setup. To supply static credentials instead, see Credentials.

Key Description Default
driver Must be cloudwatch to resolve this driver. -
name Monolog channel name used in formatted output. cloudwatch
aws.region AWS region for the CloudWatch Logs client. Required. -
aws.credentials Static credentials. Supply both key and secret, or neither (uses the default provider chain). See below. -
log_group The CloudWatch log group log records are written to. Required. -
log_stream The log stream within the group. Required. -
retention Days to retain log events; null leaves the existing policy untouched. Applied only when the group is made. 7
batch_size Number of records buffered before a flush to CloudWatch (max 10000). 1000
level Minimum Monolog level the handler will record. debug
create_group Whether to create the log group if it does not exist. true
create_stream Whether to create the log stream if it does not exist. true
tags Tags applied to the log group when it is created. []
rps_limit Requests-per-second limit before a one-second sleep is triggered; 0 disables. 0
bubble Whether records bubble to lower-priority handlers in a stack. true
cache A PSR-6 Psr\Cache\CacheItemPoolInterface instance or class string to cache group/stream existence (below). -
cache_ttl TTL in seconds for cached group/stream existence checks. 300
formatter A Monolog\Formatter\FormatterInterface instance or class string. handler default
processors Monolog processors (callables or class strings) added to the channel. []
tap Classes that receive the channel to customise it (applied by Laravel). []

Credentials

Prefer the AWS default credential provider chain - IAM roles, instance profiles, ECS task roles, or environment variables - which the example above uses by omitting aws.credentials entirely. This keeps long-lived secrets out of your application config and is the recommended production setup.

To supply static credentials instead, add an aws.credentials block with both a key and a secret (supplying only one is rejected):

Static credentials live in the channel config array, which can surface in stack traces captured by error trackers. Set zend.exception_ignore_args=1 in your production php.ini to keep argument values out of traces, or prefer the default provider chain above.

Least-privilege deployments

When the log group is provisioned out of band (Terraform, CDK) and the application's IAM role is scoped to only logs:PutLogEvents / logs:CreateLogStream, disable group creation and retention management so the handler does not attempt calls it is not permitted to make:

Structured logging

Set a formatter to ship structured records - JSON works well with CloudWatch Logs Insights:

Caching group/stream existence

Under PHP-FPM, each request re-checks (and creates, if enabled) the log group and stream on its first write. Supply a PSR-6 cache pool to share those existence checks across requests and avoid the repeated API calls:

A cache pool cannot be combined with both create_group and create_stream disabled - there would be nothing to cache.

Usage

Point a log channel at the driver: set LOG_CHANNEL=cloudwatch in your .env, or include cloudwatch in a stack channel, then log as usual:

Requirements

Testing

Changelog

See CHANGELOG.md for a list of notable changes.

Contributing

Contributions are welcome. Please read CONTRIBUTING.md for guidelines on branching, commits, code quality, and pull requests.

Security

If you discover a security vulnerability, please report it responsibly. See SECURITY.md for the disclosure policy and contact details.

License

Licensed under the Apache License, Version 2.0.


All versions of laravel-log-cloudwatch with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
aws/aws-sdk-php Version ^3.0
illuminate/log Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
monolog/monolog Version ^3.0
phpnexus/cwh Version ^3.0
psr/cache Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sinemacula/laravel-log-cloudwatch contains the following files

Loading the files please wait ...