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

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

piotrpress/logger
=================

This library is compatible with PSR-3 file logger implementation.

v2.0.0(1y ago)111122GPL-3.0PHPPHP &gt;=7.4

Since Mar 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/PiotrPress/logger)[ Packagist](https://packagist.org/packages/piotrpress/logger)[ Docs](https://github.com/PiotrPress/logger)[ RSS](/packages/piotrpress-logger/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (2)Versions (3)Used By (2)

Logger
======

[](#logger)

This library is compatible with [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) file logger implementation.

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

[](#installation)

```
composer require piotrpress/logger
```

Example
-------

[](#example)

```
require __DIR__ . '/vendor/autoload.php';

use PiotrPress\Logger;
use PiotrPress\Logger\FileHandler;
use PiotrPress\Logger\ErrorLogHandler;

$logger = new Logger(
    new FileHandler( __DIR__ . '/' . date( 'Y-m-d' ) . '.log' ),
    new ErrorLogHandler()
);

$logger->error( '[{module}] Example error', [ 'module' => 'Core' ] );
```

Saves: `[error] [Core] Example error` to file: `{Y-m-d}.log` and sends to PHP error log.

Logger
------

[](#logger-1)

[Logger](/src/Logger.php) take any number of handlers implementing [HandlerInterface](/src/Handler/HandlerInterface.php) as constructor arguments.

Handlers
--------

[](#handlers)

- [ErrorLogHandler](/src/Handler/ErrorLogHandler.php) - send logs to PHP error log.
- [FileHandler](/src/Handler/FileHandler.php) - send logs to file.

**NOTE:** Both handlers support optional [FormatterInterface](/src/Formatter/FormatterInterface.php) parameter.

Formatters
----------

[](#formatters)

- [ErrorLogFormatter](/src/Formatter/ErrorLogFormatter.php) - formats [LogRecord](/src/LogRecord.php) using [error\_log](/tpl/error_log.php) template.
- [FileFormatter](/src/Formatter/FileFormatter.php) - formats [LogRecord](/src/LogRecord.php) using [file](/tpl/file.php) template.

**NOTE:** Both formatters support optional path to `template` parameter.

Levels
------

[](#levels)

Logger supports eight log methods to write logs to the eight [RFC 5424](http://tools.ietf.org/html/rfc5424) levels (`debug`, `info`, `notice`, `warning`, `error`, `critical`, `alert`, `emergency`) and a ninth method `log`, which accepts a log level as the first argument.

Context
-------

[](#context)

All Logger log methods supports optional `context` array parameter.

All additional `context` array values, evaluated to string, can be used in `message` via corresponding keys put between a single opening brace `{` and a single closing brace `}` according to [PSR-3](https://www.php-fig.org/psr/psr-3/#13-context) guidelines.

Context values can be also used in `templates` files as regular PHP variables.

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

[](#requirements)

Supports PHP &gt;= `7.4` version.

License
-------

[](#license)

[GPL3.0](license.txt)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1271 days

Total

2

Last Release

606d ago

Major Versions

v1.0.0 → v2.0.02024-09-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10326736?v=4)[Piotr Niewiadomski](/maintainers/PiotrPress)[@PiotrPress](https://github.com/PiotrPress)

---

Top Contributors

[![PiotrPress](https://avatars.githubusercontent.com/u/10326736?v=4)](https://github.com/PiotrPress "PiotrPress (2 commits)")

---

Tags

error-loggerfile-loggerloggerlogginglogging-to-filelogsphpphp-logging-librarypsr-3psr3psr-3phplogginglogsloggerPSR3file-loggererror loggerphp logging librarylogging to file

### Embed Badge

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

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

###  Alternatives

[analog/analog

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

3451.5M24](/packages/analog-analog)[markrogoyski/simplelog-php

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

2818.1k4](/packages/markrogoyski-simplelog-php)[atrapalo/monolog-elasticsearch

A Monolog handler and formatter that makes use of the elasticsearch/elasticsearch package

1123.0k](/packages/atrapalo-monolog-elasticsearch)

PHPackages © 2026

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