PHPackages                             maxbanton/cwh - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. maxbanton/cwh

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

maxbanton/cwh
=============

AWS CloudWatch Handler for Monolog library

v3.0.0(2mo ago)42516.0M↓28.4%9020MITPHPPHP ^8.1CI passing

Since Jul 3Pushed 2mo ago8 watchersCompare

[ Source](https://github.com/maxbanton/cwh)[ Packagist](https://packagist.org/packages/maxbanton/cwh)[ Docs](https://github.com/maxbanton/cwh)[ RSS](/packages/maxbanton-cwh/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (9)Versions (29)Used By (20)

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine)

AWS CloudWatch Logs Handler for Monolog
=======================================

[](#aws-cloudwatch-logs-handler-for-monolog)

[![CI](https://github.com/maxbanton/cwh/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/maxbanton/cwh/actions/workflows/php.yml)[![Coverage Status](https://camo.githubusercontent.com/735a5a48a49b5879fdbef1022f3fcffb911130a8a1fd8b0f7a12b89bc0369ab5/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6d617862616e746f6e2f6377682f6d61737465722e737667)](https://coveralls.io/github/maxbanton/cwh?branch=master)[![License](https://camo.githubusercontent.com/caf149665127a1344675645dbadcfe0f1d85bd0e5c6bf512e3cb25f4eccebcfe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d617862616e746f6e2f6377682e737667)](https://github.com/maxbanton/cwh/blob/master/LICENSE)[![Version](https://camo.githubusercontent.com/c163589555b9d4ce5b8bc3d47dacc0b2829b492ba172e7416cc3bafc99083acc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617862616e746f6e2f6377682e737667)](https://packagist.org/packages/maxbanton/cwh)[![Downloads](https://camo.githubusercontent.com/35b8819b17c6b455b275bafd4452ccf55585401a6719fd477916d733a8c21df4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617862616e746f6e2f6377682e737667)](https://packagist.org/packages/maxbanton/cwh/stats)

Handler for PHP logging library [Monolog](https://github.com/Seldaek/monolog) for sending log entries to [AWS CloudWatch Logs](http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html) service.

Before using this library, it's recommended to get acquainted with the [pricing](https://aws.amazon.com/en/cloudwatch/pricing/) for AWS CloudWatch services.

Please press **★ Star** button if you find this library useful.

Disclaimer
----------

[](#disclaimer)

Logs are shipped to AWS CloudWatch Logs synchronously inside your PHP process. For very high-throughput workloads (thousands of records/sec sustained per process), consider an out-of-process pipeline — for example, logging to stdout and forwarding with the [CloudWatch agent](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html) — that decouples log shipping from request latency and isolates AWS API failures from your app. For typical web and worker workloads, this handler is fine.

Requirements
------------

[](#requirements)

- PHP ^8.1
- Monolog ^3.0
- AWS account with proper permissions (see list of permissions below)

Features
--------

[](#features)

- Batches up to 10,000 events per `PutLogEvents` call (the AWS per-batch maximum), with automatic flush on size (1 MB), event-timespan (24 h), or buffer-full thresholds
- Splits oversized records (&gt; 1 MB) into multiple events automatically
- Optional log-group creation with tags and retention policy
- Lazy log-group / log-stream initialization on first write
- Public `flush()` and `reset()` for long-lived workers (Symfony Messenger, Laravel queues / Octane, custom daemons)
- Suitable for web applications and for long-running CLI daemons and workers

Installation
------------

[](#installation)

Install the latest version with [Composer](https://getcomposer.org/) by running

```
$ composer require maxbanton/cwh:^3.0
```

Basic Usage
-----------

[](#basic-usage)

```
