PHPackages                             diephp/laravel-cloudwatch-logs - 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. diephp/laravel-cloudwatch-logs

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

diephp/laravel-cloudwatch-logs
==============================

Laravel Adapter for AWS CloudWatch

v1.0.2(1y ago)01.1k↓50%1[1 PRs](https://github.com/diephp/laravel-cloudwatch-logs/pulls)MITPHPPHP ^7.4 || ^8.0

Since May 23Pushed 1y agoCompare

[ Source](https://github.com/diephp/laravel-cloudwatch-logs)[ Packagist](https://packagist.org/packages/diephp/laravel-cloudwatch-logs)[ RSS](/packages/diephp-laravel-cloudwatch-logs/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

Secure Laravel Logger for AWS CloudWatch
----------------------------------------

[](#secure-laravel-logger-for-aws-cloudwatch)

### Breaking Change for Version dev-master

[](#breaking-change-for-version-dev-master)

This documentation explains how to use the PHP package with Laravel to send logs to AWS CloudWatch using a security policy that doesn't require full access to CloudWatch.

### Installation

[](#installation)

You can install it via Composer:

```
composer require diephp/laravel-cloudwatch-logs
```

Or manually add this to your `composer.json`:

```
{
    "require": {
        "diephp/laravel-cloudwatch-logs": "^1.0.0"
    }
}
```

### Usage in Laravel

[](#usage-in-laravel)

You can use this package with Laravel's default `\Log` class. Example usage:

```
\Log::error('Service error', ['message' => 'Message details', 'user_id' => \Auth()?->user_id]);
```

```
\Log::debug("Check status", [
    "status"  => "ok",
    "ver"     => app()->version(),
    "env"     => env("APP_ENV"),
    "api_url" => env("APP_URL"),
]);
```

### AWS Policy Configuration

[](#aws-policy-configuration)

Create an IAM role -&gt; Users -&gt; appName or select an existing one.

Set the Permissions policies: (This example provides full access for test/dev environments)

Log group and log stream will be created automatically (not recommended for production)

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "CloudWatchLogsFullAccess",
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents",
                "logs:DescribeLogGroups",
                "logs:DescribeLogStreams"
            ],
            "Resource": "*"
        }
    ]
}
```

Recommended configuration policies (more secure):

You must create the log group and log stream manually and set in config `'createGroup' => false,`

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "logs:PutLogEvents",
                "logs:DescribeLogGroups",
                "logs:DescribeLogStreams"
            ],
            "Resource": "*"
        }
    ]
}
```

### Laravel Configuration

[](#laravel-configuration)

Open `config/logging.php` and find the `channels` array, then add the `cloudwatch` key with minimal configuration:

```
'channels' => [
    ...
    'cloudwatch' => [
        'driver' => 'custom',
        'via' => \DiePHP\LaravelCloudWatchLog\Logger::class,
        'region' => env('AWS_REGION', 'eu-west-1'),
        'credentials' => [
            'key'    => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
        ],
    ],
    ...
]
```

For a more detailed configuration, you might want the following:

```
'channels' => [
    ...
    'cloudwatch' => [
        'driver'      => 'custom',
        'region'      => env('AWS_REGION', 'eu-west-1'),
        'credentials' => [
            'key'    => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
        ],
        'stream_name' => env('CLOUDWATCH_LOG_STREAM', 'general'),
        'retention'   => env('CLOUDWATCH_LOG_RETENTION_DAYS', 31),
        'group_name'  => env('CLOUDWATCH_LOG_GROUP_NAME', env('AWS_SDK_LOG_GROUP_PREFIX', '')."general"),
        'version'     => env('CLOUDWATCH_LOG_VERSION', 'latest'),
        'formatter'   => \Monolog\Formatter\JsonFormatter::class,
        'batch_size'  => env('CLOUDWATCH_LOG_BATCH_SIZE', 10000), // max buffer size to send in one batch
        'level'       => env('LOG_LEVEL', 'debug'),
        'createGroup' => true, // This is related to the AWS policy you choose.
        'bubble'      => true, // Whether the messages that are handled can bubble up the stack or not
        'extra'       => [
            'env'     => env('APP_ENV'),
            'php'     => PHP_VERSION,
            'laravel' => app()->version(),
        ],
        'tags'        => ['tag1', 'tag2'],
        'via'         => \DiePHP\LaravelCloudWatchLog\Logger::class,
    ],
    ...
]
```

If you use AWS infrastructure for deployment, you can remove the `credentials` section from the config because AWS containers already have credentials for aws-sdk.

Then, you should set the `LOG_CHANNEL` in your environment variables to `cloudwatch`.

Keep in mind that you should replace the `env` values with the actual ones you plan to use.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance44

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~143 days

Total

3

Last Release

439d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/843845c3857f227042e7ae4ea3f5e255f8e14fc59d6a971b72bc0670996e7701?d=identicon)[diephp](/maintainers/diephp)

---

Top Contributors

[![developernaren](https://avatars.githubusercontent.com/u/3628468?v=4)](https://github.com/developernaren "developernaren (33 commits)")[![FoxxMD](https://avatars.githubusercontent.com/u/4663766?v=4)](https://github.com/FoxxMD "FoxxMD (4 commits)")[![hungnv-sr](https://avatars.githubusercontent.com/u/25086528?v=4)](https://github.com/hungnv-sr "hungnv-sr (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![rmundel](https://avatars.githubusercontent.com/u/13142574?v=4)](https://github.com/rmundel "rmundel (2 commits)")[![AnatolyAstapov](https://avatars.githubusercontent.com/u/12308843?v=4)](https://github.com/AnatolyAstapov "AnatolyAstapov (1 commits)")[![sujansh](https://avatars.githubusercontent.com/u/1407947?v=4)](https://github.com/sujansh "sujansh (1 commits)")[![luigel](https://avatars.githubusercontent.com/u/26235960?v=4)](https://github.com/luigel "luigel (1 commits)")[![Martenvanurk](https://avatars.githubusercontent.com/u/747146?v=4)](https://github.com/Martenvanurk "Martenvanurk (1 commits)")[![naveenk87](https://avatars.githubusercontent.com/u/7149360?v=4)](https://github.com/naveenk87 "naveenk87 (1 commits)")[![niekvanderkooy](https://avatars.githubusercontent.com/u/1261369?v=4)](https://github.com/niekvanderkooy "niekvanderkooy (1 commits)")

---

Tags

laravelawslogsloggercloudwatch

### Embed Badge

![Health badge](/badges/diephp-laravel-cloudwatch-logs/health.svg)

```
[![Health](https://phpackages.com/badges/diephp-laravel-cloudwatch-logs/health.svg)](https://phpackages.com/packages/diephp-laravel-cloudwatch-logs)
```

###  Alternatives

[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[jackiedo/log-reader

An easy log reader and management tool for Laravel

151376.5k4](/packages/jackiedo-log-reader)[kssadi/log-tracker

A powerful, intuitive, and efficient log viewer for Laravel applications.

264.8k](/packages/kssadi-log-tracker)[hryha/laravel-request-logger

A Laravel package to log requests and responses

102.2k](/packages/hryha-laravel-request-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
