PHPackages                             ez-php/logging - 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. [Framework](/categories/framework)
4. /
5. ez-php/logging

ActiveLibrary[Framework](/categories/framework)

ez-php/logging
==============

Logging module for the ez-php framework — structured logging with file, stdout, and null drivers

1.11.1(1mo ago)030MITPHPPHP ^8.5CI passing

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/logging)[ Packagist](https://packagist.org/packages/ez-php/logging)[ Docs](https://github.com/ez-php/logging)[ RSS](/packages/ez-php-logging/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (18)Versions (44)Used By (0)

ez-php/logging
==============

[](#ez-phplogging)

Logging module for the [ez-php framework](https://github.com/ez-php/framework) — structured logging with pluggable drivers, minimum-level filtering, JSON formatting, request context injection, and automatic exception logging.

[![CI](https://github.com/ez-php/logging/actions/workflows/ci.yml/badge.svg)](https://github.com/ez-php/logging/actions/workflows/ci.yml)

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

[](#requirements)

- PHP 8.5+
- ez-php/framework 0.\*

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

[](#installation)

```
composer require ez-php/logging
```

Setup
-----

[](#setup)

Register the service provider:

```
$app->register(\EzPhp\Logging\LogServiceProvider::class);
```

Configure in `config/logging.php`:

```
return [
    'driver'    => env('LOG_DRIVER', 'file'), // file | stdout | null | json | stack
    'path'      => env('LOG_PATH', 'storage/logs'),
    'min_level' => env('LOG_MIN_LEVEL', ''),  // DEBUG|INFO|WARNING|ERROR|CRITICAL — empty = all
    'json_inner'=> env('LOG_JSON_INNER', 'stdout'), // inner driver when driver=json
    'stack'     => ['file', 'stdout'],              // used when driver=stack
];
```

Usage
-----

[](#usage)

```
use EzPhp\Logging\Log;

Log::debug('Cache miss', ['key' => 'users.all']);
Log::info('User registered', ['id' => 42]);
Log::warning('Rate limit approaching', ['remaining' => 5]);
Log::error('Payment failed', ['order' => 'ORD-99']);
Log::critical('Database unreachable');

// Generic level dispatch
Log::log('info', 'Something happened');
```

Drivers
-------

[](#drivers)

DriverDescription`file`Appends to `{path}/app-YYYY-MM-DD.log` (daily rotation)`stdout``debug`/`info`/`warning` → stdout · `error`/`critical` → stderr`null`Discards all entries — useful in tests`json`Decorator: serialises entries as JSON and forwards to an inner driver`stack`Decorator: fans each call out to multiple inner drivers simultaneouslyWrap any driver with a minimum-level filter by setting `LOG_MIN_LEVEL`:

```
LOG_DRIVER=file
LOG_MIN_LEVEL=WARNING   # drops DEBUG and INFO entries
```

JSON structured logging
-----------------------

[](#json-structured-logging)

```
LOG_DRIVER=json
LOG_JSON_INNER=stdout
```

Each entry is written as a single JSON line:

```
{"timestamp":"2026-03-21T12:00:00+00:00","level":"info","message":"tick.event","context":{"user_id":5}}
```

Stack driver
------------

[](#stack-driver)

Write to multiple destinations simultaneously:

```
LOG_DRIVER=stack
```

```
// config/logging.php
return [
    'driver' => 'stack',
    'stack'  => ['file', 'stdout'],
];
```

Request context middleware
--------------------------

[](#request-context-middleware)

`RequestContextMiddleware` injects `request_id`, `ip`, `method`, and `path` into every log entry produced during a request:

```
$app->middleware(\EzPhp\Logging\RequestContextMiddleware::class);
```

The middleware wraps the current logger in a `ContextualLogger` and restores the original logger in `finally`.

Exception logging
-----------------

[](#exception-logging)

`LogServiceProvider` automatically wraps the `ExceptionHandler` with `LoggingExceptionHandler`, so all unhandled exceptions are logged at `error` level (with exception class, code, file, and line) before the response is rendered. No extra configuration needed.

Log format (file/stdout)
------------------------

[](#log-format-filestdout)

```
[2026-03-15 12:00:00] INFO: User registered {"id":42}
[2026-03-15 12:00:01] ERROR: Payment failed {"order":"ORD-99"}

```

Classes
-------

[](#classes)

ClassDescription`LoggerInterface`Contract: `log()`, `debug()`, `info()`, `warning()`, `error()`, `critical()``LogLevel`Backed enum: `DEBUG|INFO|WARNING|ERROR|CRITICAL`; `severity()`, `isAtLeast()``FileDriver`Appends to daily-rotated log files; creates directory on demand`StdoutDriver`stdout for debug/info/warning, stderr for error/critical`NullDriver`No-op — discards all entries`JsonDriver`Decorator: serialises entries as JSON, forwards to inner driver`StackDriver`Decorator: fans calls out to a list of inner drivers`MinLevelDriver`Decorator: drops entries below a configured minimum severity`ContextualLogger`Decorator: merges a fixed context array into every log call`RequestContextMiddleware`Injects request\_id/ip/method/path context for the duration of a request`Log`Static façade backed by a managed `LoggerInterface` singleton`LoggingExceptionHandler`Decorator: logs exceptions at error level, then delegates to inner handler`LogServiceProvider`Config-driven driver binding; wraps `ExceptionHandler`; wires `Log` façadeLicense
-------

[](#license)

MIT — [Andreas Uretschnig](mailto:andreas.uretschnig@gmail.com)

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance91

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 90.6% 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 ~1 days

Total

43

Last Release

43d ago

Major Versions

0.9.3 → 1.0.02026-03-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/122030400?v=4)[AU9500](/maintainers/AU9500)[@AU9500](https://github.com/AU9500)

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (126 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")

---

Tags

phpframeworkloggingloggerez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ez-php-logging/health.svg)

```
[![Health](https://phpackages.com/badges/ez-php-logging/health.svg)](https://phpackages.com/packages/ez-php-logging)
```

###  Alternatives

[utopia-php/logger

Utopia Logger library is simple and lite library for logging information, such as errors or warnings. This library is aiming to be as simple and easy to learn and use.

11247.6k4](/packages/utopia-php-logger)

PHPackages © 2026

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