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

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

maatify/slim-logger
===================

Slim-compatible structured logger with PSR-7 request support

1.0.6(1y ago)0111MITPHPPHP &gt;=8.2.0CI passing

Since Apr 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Maatify/slim-logger)[ Packagist](https://packagist.org/packages/maatify/slim-logger)[ Docs](https://github.com/Maatify/)[ RSS](/packages/maatify-slim-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

Maatify Slim Logger
===================

[](#maatify-slim-logger)

---

[![Maatify.dev](https://camo.githubusercontent.com/bb8bf9ee079d7f823c9d5e94061d1d4c11dc0898e2b1b5cc9a8a7b04d8bfdd7d/68747470733a2f2f7777772e6d6161746966792e6465762f6173736574732f696d672f696d672f6d6161746966795f6c6f676f5f77686974652e737667)](https://camo.githubusercontent.com/bb8bf9ee079d7f823c9d5e94061d1d4c11dc0898e2b1b5cc9a8a7b04d8bfdd7d/68747470733a2f2f7777772e6d6161746966792e6465762f6173736574732f696d672f696d672f6d6161746966795f6c6f676f5f77686974652e737667)

---

[![Current version](https://camo.githubusercontent.com/69847b6de5f088d53cfd77e764408187e7c7470d12e6bd77a2ad9feceb1d55b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6161746966792f736c696d2d6c6f67676572)](https://packagist.org/packages/maatify/slim-logger)[![Packagist PHP Version Support](https://camo.githubusercontent.com/7cc083ff599ead5af537c1c78f5f6ce85d3fca668adbd9aba1145ba3683a52d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6161746966792f736c696d2d6c6f67676572)](https://packagist.org/packages/maatify/slim-logger)[![Monthly Downloads](https://camo.githubusercontent.com/99ca500a42dac37afb9016d3dd870c1bd5276a6713d30758b2c073b2f5b3cc8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d6161746966792f736c696d2d6c6f67676572)](https://packagist.org/packages/maatify/slim-logger/stats)[![Total Downloads](https://camo.githubusercontent.com/a7b2ea0f8f2849c10e5ce00921a5961e3d1e94cff533ad5cd7b4d735adb9802a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6161746966792f736c696d2d6c6f67676572)](https://packagist.org/packages/maatify/slim-logger/stats)[![Stars](https://camo.githubusercontent.com/c5affd0ea11256b050336733e2692aa30f6100a6261a4b4cbf96a39e73af59bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6d6161746966792f736c696d2d6c6f67676572)](https://github.com/maatify/slim-logger/stargazers)

[![Tests](https://github.com/maatify/slim-logger/actions/workflows/run-tests.yml/badge.svg)](https://github.com/maatify/slim-logger/actions)

**Maatify Slim Logger** is a lightweight, PSR-7 compatible, Slim-friendly structured logger for PHP applications. It is part of the modular [Maatify](https://maatify.dev) ecosystem.

---

🚀 Features
----------

[](#-features)

- ✅ PSR-7 request-aware logging (integrates with Slim Framework)
- ✅ Uses `LogLevelEnum` (PHP 8.1+)
- ✅ Logs to file in JSON format
- ✅ File names include log level (`_response_error_...`)
- ✅ Static access with `Logger::recordStatic()`
- ✅ Automatically creates secure log directories
- ✅ Works with Slim or pure PHP
- ✅ GitHub Actions CI ready

---

📦 Installation
--------------

[](#-installation)

```
composer require maatify/slim-logger
```

---

🧱 Namespaces
------------

[](#-namespaces)

- Logger: `Maatify\SlimLogger\Log\Logger`
- Enum: `Maatify\SlimLogger\Log\LogLevelEnum`
- Path Helper: `Maatify\SlimLogger\Store\File\Path`

---

📁 Folder Structure
------------------

[](#-folder-structure)

```
maatify-slim-logger/
├── src/
│   └── Log/
│       ├── Logger.php
│       └── LogLevelEnum.php
│   └── Store/
│       └── File/
│           └── Path.php

```

---

✅ Basic Usage (Slim or Plain PHP)
---------------------------------

[](#-basic-usage-slim-or-plain-php)

```
use Maatify\SlimLogger\Log\Logger;
use Maatify\SlimLogger\Log\LogLevelEnum;
use Maatify\SlimLogger\Store\File\Path;

$logger = new Logger(new Path(__DIR__));
$logger->record('User login', null, 'user/actions', LogLevelEnum::Info);
```

---

💡 Usage in Slim Route
---------------------

[](#-usage-in-slim-route)

```
$app->post('/action', function ($request, $response) use ($logger) {
    $logger->record('User posted action.', $request, 'user/submit', LogLevelEnum::Debug);
    return $response;
});
```

---

⚠️ Logging Exceptions
---------------------

[](#️-logging-exceptions)

```
try {
    throw new \Exception('Oops');
} catch (\Throwable $e) {
    $logger->record($e, null, 'errors/runtime', LogLevelEnum::Error);
}
```

---

📣 Static Logging
----------------

[](#-static-logging)

Log from anywhere — no need to instantiate:

```
use Maatify\SlimLogger\Log\Logger;
use Maatify\SlimLogger\Log\LogLevelEnum;

Logger::recordStatic('Static log entry.', null, 'system/status', LogLevelEnum::Info);
```

### ✅ Static Exception Example

[](#-static-exception-example)

```
try {
    throw new \Exception("Static exception!");
} catch (\Throwable $e) {
    Logger::recordStatic($e, null, 'errors/fatal', LogLevelEnum::Error);
}
```

---

🧪 (Advanced) Overriding Static Instance for Testing
---------------------------------------------------

[](#-advanced-overriding-static-instance-for-testing)

In PHPUnit or setup environments, use:

```
$testLogger = new Logger(new Path(__DIR__ . '/logs'));
Logger::setInstance($testLogger);
```

Then `recordStatic()` will use that injected instance and path.

---

🔍 Log File Naming Example
-------------------------

[](#-log-file-naming-example)

```
/logs/24/04/18/user/actions_response_info_20250418AM.log

```

---

⚙️ Configuration
----------------

[](#️-configuration)

OptionDefaultDescription`Path`project rootBase path for log files`Extension``.log`File extension for log files---

🧪 Run Tests Locally
-------------------

[](#-run-tests-locally)

```
composer test
```

---

🚀 GitHub CI Integration
-----------------------

[](#-github-ci-integration)

Tests run automatically on push via:

`.github/workflows/run-tests.yml`

---

📄 License
---------

[](#-license)

[MIT License](./LICENSE) © 2025 [Maatify.dev](https://maatify.dev)

---

🙋‍♂️ Questions?
---------------

[](#‍️-questions)

- GitHub: [github.com/maatify/slim-logger](https://github.com/maatify/slim-logger)

---

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance47

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

390d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a885a0810f2762586520ab284c9019aaf0b650b53cdf2a6c13ea10931bb7795?d=identicon)[Maatify](/maintainers/Maatify)

---

Top Contributors

[![megyptm](https://avatars.githubusercontent.com/u/33574895?v=4)](https://github.com/megyptm "megyptm (12 commits)")[![Maatify](https://avatars.githubusercontent.com/u/130119162?v=4)](https://github.com/Maatify "Maatify (2 commits)")

---

Tags

slimloggermaatify

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[analog/analog

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

3451.5M24](/packages/analog-analog)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1851.5M3](/packages/justbetter-magento2-sentry)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[inpsyde/wonolog

Monolog-based logging package for WordPress.

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

Non-blocking logging for PHP based on Amp, Revolt, and Monolog.

402.6M70](/packages/amphp-log)

PHPackages © 2026

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