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

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

eliashaeussler/transient-logger
===============================

PSR-3 compliant logger to store logs in memory, especially useful for testing

2.0.0(7mo ago)1226.6k↑24.1%[1 issues](https://github.com/eliashaeussler/transient-logger/issues)4GPL-3.0-or-laterPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Nov 23Pushed 2w ago1 watchersCompare

[ Source](https://github.com/eliashaeussler/transient-logger)[ Packagist](https://packagist.org/packages/eliashaeussler/transient-logger)[ RSS](/packages/eliashaeussler-transient-logger/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (9)Versions (9)Used By (4)

Transient PSR-3 logger
======================

[](#transient-psr-3-logger)

[![Coverage](https://camo.githubusercontent.com/2aab466efdbe896b2e905aa93be0181b4b4c549fefe2a23b9f24c94247833e69/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c73436f7665726167652f6769746875622f656c6961736861657573736c65722f7472616e7369656e742d6c6f676765723f6c6f676f3d636f766572616c6c73)](https://coveralls.io/github/eliashaeussler/transient-logger)[![CI](https://camo.githubusercontent.com/82b8aec4ffae2ddd117bc0d333ff5cf9907f1138eb2c2daee9fd2327b7be5682/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656c6961736861657573736c65722f7472616e7369656e742d6c6f676765722f63692e79616d6c3f6c6162656c3d4349266c6f676f3d676974687562)](https://github.com/eliashaeussler/transient-logger/actions/workflows/ci.yaml)[![Supported PHP Versions](https://camo.githubusercontent.com/0f2606806008a3593eccb97299aae6c315923ac12329f3b5b82520ba77b51307/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f656c6961736861657573736c65722f7472616e7369656e742d6c6f676765722f7068703f6c6f676f3d706870)](https://packagist.org/packages/eliashaeussler/transient-logger)

This library provides a small PSR-3 compliant logger to stores log records in memory. Each log is converted to a log record and attached to the current logger instance. Logs will be available as long as the logger object is available in memory. This is especially useful for testing applications and libraries.

🔥 Installation
--------------

[](#-installation)

[![Packagist](https://camo.githubusercontent.com/975f94b361da4699047a976b6a9daf29c9b2757d69cbe3ccc6438d7f80fbb4eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6961736861657573736c65722f7472616e7369656e742d6c6f676765723f6c6162656c3d76657273696f6e266c6f676f3d7061636b6167697374)](https://packagist.org/packages/eliashaeussler/transient-logger)[![Packagist Downloads](https://camo.githubusercontent.com/9695f90946723abbb025b6f59c10a03477e2a6e04b3d4422845632c9467fe5fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c6961736861657573736c65722f7472616e7369656e742d6c6f676765723f636f6c6f723d627269676874677265656e)](https://packagist.org/packages/eliashaeussler/transient-logger)

```
composer require --dev eliashaeussler/transient-logger
```

⚡ Usage
-------

[](#-usage)

### Create logger

[](#create-logger)

The library provides a [`TransientLogger`](src/TransientLogger.php) class which implements PSR's [`LoggerInterface`](https://github.com/php-fig/log/blob/master/src/LoggerInterface.php). You can use it just like any other PSR-3 compliant logger:

```
use EliasHaeussler\TransientLogger;

$logger = new TransientLogger\TransientLogger();
```

### Log messages

[](#log-messages)

For each logged message, a new [`Log\LogRecord`](src/Log/LogRecord.php) is created and attached to the logger instance. The appropriate log levels are represented by a [`Log\LogLevel`](src/Log/LogLevel.php) enum which is a wrapper around PSR's [`LogLevel`](https://github.com/php-fig/log/blob/master/src/LogLevel.php) constants.

```
// Log using generic log() method
$logger->log(
    TransientLogger\Log\LogLevel::Alert,
    'Houston, we have a problem!',
    ['error' => 'rocket down'],
);

// Log using specific methods
$logger->alert('Houston, we have a problem!', ['error' => 'rocket down']);
```

### Access log records

[](#access-log-records)

You can access all log records in several ways:

```
// Get all log records
$logs = $logger->getAll();

// Get by specific log level
$errors = $logger->getByLogLevel(TransientLogger\Log\LogLevel::Error);

// Iterate over log records
foreach ($logger as $logRecord) {
    $level = $logRecord->level; // instanceof \EliasHaeussler\TransientLogger\Log\LogLevel
    $message = $logRecord->message; // string or instanceof Stringable
    $context = $logRecord->context; // array
}
```

### Flush log

[](#flush-log)

If required, you can always flush the log attached to a logger:

```
$logger->flushLog();
```

🧑‍💻 Contributing
----------------

[](#‍-contributing)

Please have a look at [`CONTRIBUTING.md`](CONTRIBUTING.md).

⭐ License
---------

[](#-license)

This project is licensed under [GNU General Public License 3.0 (or later)](LICENSE).

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance62

Regular maintenance activity

Popularity35

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 82.8% 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 ~242 days

Total

4

Last Release

227d ago

Major Versions

1.1.0 → 2.0.02025-11-18

PHP version history (4 changes)1.0.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

1.0.1PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

1.1.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

2.0.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16313625?v=4)[Elias Häußler](/maintainers/eliashaeussler)[@eliashaeussler](https://github.com/eliashaeussler)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (424 commits)")[![eliashaeussler](https://avatars.githubusercontent.com/u/16313625?v=4)](https://github.com/eliashaeussler "eliashaeussler (88 commits)")

---

Tags

logloggermemorypsr-3transient

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k247.1M334](/packages/sentry-sentry)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.3k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[illuminate/log

The Illuminate Log package.

6225.3M621](/packages/illuminate-log)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.0M219](/packages/api-platform-metadata)

PHPackages © 2026

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