Download the PHP package aporat/laravel-cloudwatch-logger without Composer

On this page you can find all versions of the php package aporat/laravel-cloudwatch-logger. 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-cloudwatch-logger

Laravel CloudWatch Logger

Latest Stable Version Downloads Codecov Laravel Version GitHub Actions Workflow Status

A Laravel logging driver for AWS CloudWatch Logs.

Features

Requirements

Installation

The service provider is auto-discovered. It registers a cloudwatch logging channel from the package defaults, so this already works:

To customise it, publish the config:

The published config/cloudwatch-logger.php is a complete channel definition. If you define a cloudwatch channel yourself in config/logging.php, yours wins and the package leaves it alone.

Defining channels

A channel is a normal Laravel custom driver entry:

Leave both credential values empty to use the AWS default credential chain (IAM task/instance role, environment variables, ~/.aws/credentials). The empty block is removed before the client is built, so the SDK doesn't reject it.

Options

Key Type Default Description
aws array — Passed to the CloudWatchLogsClient constructor. region and version are required.
group string — Log group. Letters, digits, _, -, /, ., #; max 512 chars.
stream string — Log stream within the group. No : or *; max 512 chars.
name string — Monolog channel name, used by %channel%.
level string|int|Level debug Minimum level. Accepts a Monolog\Level, a severity number, or a level name.
formatter string|class|instance|callable LineFormatter See Formatters.
replace_placeholders bool false Interpolate {placeholders} from the context, as Laravel's other channels do.
retention int|null 14 Days to retain events, or null to never expire. Must be one of CloudWatch's accepted periods. Applied only when this package creates the group.
batch_size int 10000 Events buffered before a PutLogEvents call. 1–10000.
rps_limit int 0 Self-throttle to this many requests per second; 0 disables.
tags array<string,string> [] Tags applied when the group is created.
bubble bool true Whether records continue to other handlers.
create_group bool true Create the log group if missing.
create_stream bool true Create the log stream if missing.
cache bool|string|class|pool false See Avoiding the per-process describe calls.
cache_ttl int 300 Lifetime, in seconds, of a cached "group/stream exists" marker.
suppress_failures bool false Drop the log line instead of throwing when CloudWatch is unreachable.

Every one of these also accepts the string form env() produces, so CLOUDWATCH_LOG_BATCH_SIZE=25 and 'batch_size' => 25 behave identically.

Choosing a batch size

batch_size buffers events in memory and sends them in one PutLogEvents call. The right value depends on how long the process lives:

CloudWatch throttles PutLogEvents per stream. When it does, the handler sleeps for a second and retries, which blocks the process. If a stream is busy enough to hit that, set rps_limit so the handler paces itself instead.

Avoiding the per-process describe calls

By default the handler issues a DescribeLogGroups and a DescribeLogStreams call on the first write of every process, for every channel, to find out whether it needs to create them. Set cache to remember the answer:

Entries are namespaced per log group, so two channels writing to a same-named stream in different groups don't collide. Cache failures degrade to a miss — the handler just asks CloudWatch again.

If the group and stream are provisioned outside the application (Terraform, CloudFormation), set create_group and create_stream to false instead and skip the lookups entirely.

Failure handling

A log write that can't reach CloudWatch throws. In a request path that logs its own errors, that turns a handled failure into a 500. Set 'suppress_failures' => true to wrap the handler in Monolog's WhatFailureGroupHandler, which drops the record instead.

For a local fallback rather than a silent drop, use a Laravel stack channel:

Formatters

formatter accepts four shapes:

A string that looks like a class name but doesn't resolve to a FormatterInterface is rejected, rather than being silently used as a format template.

Configuration errors

Invalid configuration throws Aporat\CloudWatchLogger\Exceptions\IncompleteCloudWatchConfig while the channel is being built.

Note that Laravel's LogManager catches anything a channel factory throws and substitutes its emergency file logger (storage/logs/laravel.log). So a misconfigured channel does not raise at the call site — it stops reaching CloudWatch, and the reason is written to the emergency log. Worth checking there if a channel goes quiet after a config change.

Testing

Contributing

See SECURITY.md.

License

MIT. See LICENSE.


All versions of laravel-cloudwatch-logger with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-json Version *
aws/aws-sdk-php Version ^3.300
illuminate/contracts Version ^12.0 || ^13.0
illuminate/log Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
monolog/monolog Version ^3.6
phpnexus/cwh Version ^3.2
psr/cache Version ^2.0 || ^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 aporat/laravel-cloudwatch-logger contains the following files

Loading the files please wait ...