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(6mo ago)1204.1k↓12.6%[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 1mo 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 1mo ago

READMEChangelog (4)Dependencies (9)Versions (6)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)[![CGL](https://camo.githubusercontent.com/26e07637b54e3c8be52ea4add227d1db719957333f37ac5c2271bb3af9e60996/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656c6961736861657573736c65722f7472616e7369656e742d6c6f676765722f63676c2e79616d6c3f6c6162656c3d63676c266c6f676f3d676974687562)](https://github.com/eliashaeussler/transient-logger/actions/workflows/cgl.yaml)[![Tests](https://camo.githubusercontent.com/9501295be31957b65424e41d7586e1d8ca2f1b129c0db053ae578f2b90acf303/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656c6961736861657573736c65722f7472616e7369656e742d6c6f676765722f74657374732e79616d6c3f6c6162656c3d7465737473266c6f676f3d676974687562)](https://github.com/eliashaeussler/transient-logger/actions/workflows/tests.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

47

—

FairBetter than 94% of packages

Maintenance60

Regular maintenance activity

Popularity35

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 82.5% 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

181d 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://www.gravatar.com/avatar/144cefe55242b883c87cb537463f3ba75a0f8198fc5b602b50c838aae31fe7ee?d=identicon)[eliashaeussler](/maintainers/eliashaeussler)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (377 commits)")[![eliashaeussler](https://avatars.githubusercontent.com/u/16313625?v=4)](https://github.com/eliashaeussler "eliashaeussler (80 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.9k227.1M273](/packages/sentry-sentry)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[illuminate/log

The Illuminate Log package.

6224.3M518](/packages/illuminate-log)[open-telemetry/api

API for OpenTelemetry PHP.

1933.0M214](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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