PHPackages                             bref/logger - 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. bref/logger

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

bref/logger
===========

All you need to log with Bref on AWS Lambda

2.0.0(11mo ago)331.5M↑11.9%4[2 issues](https://github.com/brefphp/logger/issues)[1 PRs](https://github.com/brefphp/logger/pulls)7MITPHPPHP &gt;=8.0CI passing

Since Mar 6Pushed 11mo ago2 watchersCompare

[ Source](https://github.com/brefphp/logger)[ Packagist](https://packagist.org/packages/bref/logger)[ GitHub Sponsors](https://github.com/mnapoli)[ RSS](/packages/bref-logger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (7)

All you need to log with [Bref](https://bref.sh) on AWS Lambda.

Bref/Logger is a lightweight [PSR-3](https://www.php-fig.org/psr/psr-3/) logger for AWS Lambda. Messages are sent to `stderr` so that they end up in [CloudWatch](https://bref.sh/docs/environment/logs.html).

Why?
----

[](#why)

As explained in [the Bref documentation](https://bref.sh/docs/environment/logs.html), logging in AWS Lambda means logging to `stderr`. Logs written to `stderr` are automatically sent to [CloudWatch](https://aws.amazon.com/cloudwatch/), AWS' solution to collect and view logs.

While classic loggers like [Monolog](https://github.com/Seldaek/monolog) work fine, this logger comes as a simpler and lighter alternative optimized for AWS Lambda. It does not require any configuration and currently contains a single class.

Since it is [PSR-3](https://www.php-fig.org/psr/psr-3/) compliant, Bref/Logger is also compatible with any framework or library consuming a PSR-3 logger.

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

[](#installation)

```
composer require bref/logger

```

Usage
-----

[](#usage)

The logger does not require any configuration:

```
$logger = new \Bref\Logger\StderrLogger();
```

By default, messages **above the `info` level** will be logged, the rest will be discarded.

It is possible to log using any [PSR-3 log level](https://www.php-fig.org/psr/psr-3/#5-psrlogloglevel), the most common ones being:

```
$logger->debug('This is a debug message');
$logger->info('This is an info');
$logger->warning('This is a warning');
$logger->error('This is an error');
```

```
INFO	This is an info	{"message":"This is an info","level":"INFO"}
WARNING	This is a warning	{"message":"This is a warning","level":"WARNING"}
ERROR	This is an error	{"message":"This is an error","level":"ERROR"}

```

Messages under `info` are not logged.

### Message placeholders

[](#message-placeholders)

[PSR-3 placeholders](https://www.php-fig.org/psr/psr-3/#12-message) can be used to insert information from the `$context` array into the message without having to concatenate strings manually:

```
$logger->warning('Invalid login attempt for email {email}', [
    'email' => $email,
]);
```

```
WARNING	Invalid login attempt for email johndoe@example.com	{"message":"Invalid login attempt for email johndoe@example.com","level":"WARNING","context":{"email":"johndoe@example.com"}}

```

### Logging exceptions

[](#logging-exceptions)

Exceptions [can be logged](https://www.php-fig.org/psr/psr-3/#13-context) under the `exception` key:

```
try {
   // ...
} catch (\Exception $e) {
    $logger->error('Impossible to complete the action', [
        'exception' => $e,
    ]);
}
```

```
ERROR	Impossible to complete the action	{"message":"Impossible to complete the action","level":"ERROR","exception":{"class":"InvalidArgumentException","message":"Impossible to complete the action","code":0,"file":"/var/task/index.php","line":12,"trace":[{"file":"/var/task/index.php","line":86,"function":"main"}]}

```

### Log level

[](#log-level)

It is possible to change the level above which messages are logged.

For example to log all messages:

```
$logger = new \Bref\Logger\StderrLogger(\Psr\Log\LogLevel::DEBUG);
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance51

Moderate activity, may be stable

Popularity51

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 89.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 ~572 days

Total

5

Last Release

339d ago

Major Versions

0.1.0 → 1.0.02019-06-27

1.0.2 → 2.0.02025-06-14

PHP version history (3 changes)0.1.0PHP ^7.2

1.0.1PHP &gt;=7.2

2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/329a6111724074f5388e95dd41a03ccf3c43f4bfe1ecf27c94c9efc6f7823228?d=identicon)[mnapoli](/maintainers/mnapoli)

---

Top Contributors

[![mnapoli](https://avatars.githubusercontent.com/u/720328?v=4)](https://github.com/mnapoli "mnapoli (25 commits)")[![deleugpn](https://avatars.githubusercontent.com/u/9533181?v=4)](https://github.com/deleugpn "deleugpn (2 commits)")[![ionl](https://avatars.githubusercontent.com/u/3930248?v=4)](https://github.com/ionl "ionl (1 commits)")

---

Tags

aws-lambdabrefloggerpsr-3serverlesspsr-3loggerlambdabrefcloudwatchaws-lambda

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bref-logger/health.svg)

```
[![Health](https://phpackages.com/badges/bref-logger/health.svg)](https://phpackages.com/packages/bref-logger)
```

###  Alternatives

[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3451.5M24](/packages/analog-analog)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

511.0M18](/packages/apix-log)[bref/monolog-bridge

Monolog formatter optimized for AWS Lambda and CloudWatch

111.2M3](/packages/bref-monolog-bridge)[markrogoyski/simplelog-php

Powerful PSR-3 logging. So easy, it's simple.

2818.1k4](/packages/markrogoyski-simplelog-php)[wa72/simplelogger

Wa72SimpleLogger is a collection of very simple loggers implementing \\Psr\\Log\\LoggerInterface (PSR-3)

13246.6k13](/packages/wa72-simplelogger)

PHPackages © 2026

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