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

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

anekdotes/logger
================

A logger class to log JSON messages

1.0.0(4y ago)1626[1 issues](https://github.com/anekdotes/logger/issues)MITPHPPHP &gt;=7.4.0

Since Apr 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/anekdotes/logger)[ Packagist](https://packagist.org/packages/anekdotes/logger)[ RSS](/packages/anekdotes-logger/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (14)Used By (0)

Anekdotes Logger
================

[](#anekdotes-logger)

[![Latest Stable Version](https://camo.githubusercontent.com/b264c8ea8cbb140d9b11c0caf3e304f576e8a0bd1a2a8e8a61f7dc6e6b0b14d0/68747470733a2f2f706f7365722e707567782e6f72672f616e656b646f7465732f6c6f676765722f762f737461626c65)](https://packagist.org/packages/anekdotes/logger)[![Build Status](https://camo.githubusercontent.com/23e84dad205222a8ab6b7258a9efae68c7dd84f1a0ec5a376aadf6836ffe4472/68747470733a2f2f7472617669732d63692e6f72672f616e656b646f7465732f6c6f676765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/anekdotes/logger)[![License](https://camo.githubusercontent.com/8ee79b11eb54047d7f1ee9eb498878552f106aa3daedd9be38de7774becba9b0/68747470733a2f2f706f7365722e707567782e6f72672f616e656b646f7465732f6c6f676765722f6c6963656e7365)](https://packagist.org/packages/anekdotes/logger)[![Total Downloads](https://camo.githubusercontent.com/8025cc5a973e4386e4007c073031553e918c32e6c6864e06c7b0081bb65faf80/68747470733a2f2f706f7365722e707567782e6f72672f616e656b646f7465732f6c6f676765722f646f776e6c6f616473)](https://packagist.org/packages/anekdotes/logger)[![Codacy Badge](https://camo.githubusercontent.com/7912868bf20839bf1eb30ac4be775ddd7b7be8e75aadb39b8421d178edfab20c/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3633653265633338656563343433366661393230333033393365646538613662)](https://www.codacy.com/app/steve-gagnev4si/logger?utm_source=github.com&utm_medium=referral&utm_content=anekdotes/logger&utm_campaign=Badge_Grade)

Allows logging of JSON messages, to easily be integrated in a static class.

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

[](#installation)

Install via composer into your project:

```
composer require anekdotes/logger

```

Basic Usage
-----------

[](#basic-usage)

To use the logger, call its namespace and build a context array.

```
    use Anekdotes\Logger\Log;
    Log::info(["message" => "toaster","user_identification" => "4N3K"]);
```

Logging Drivers
---------------

[](#logging-drivers)

The system logs to the PHP console by default. Setting a different driver will change its behavior

### File Driver

[](#file-driver)

To log to files, a FileDriver must be set.

```
    use Anekdotes\Logger\Log;
    use Anekdotes\Logger\Drivers\FileDriver;
    //Set Driver and use it
    Log::setDriver(new FileDriver('logname','tmp/logs/toaster.log'));
    Log::info(["message" => "toaster","user_identification" => "4N3K"]);
```

### Console Driver

[](#console-driver)

Logs a file to the PHP Console. Used by default, but this can be used if another driver was previously set

```
    use Anekdotes\Logger\Log;
    use Anekdotes\Logger\Drivers\FileDriver;
    //Set Driver and use it
    Log::setDriver(new ConsoleDriver());
    Log::info(["message" => "toaster","user_identification" => "4N3K"]);
```

Handlers
--------

[](#handlers)

You can use handlers to have the logger run additional tasks on error and critical logs. Handlers are Anonymous functions that are set by using their accessors.

```
    $data = ["data" => "data"];
    $functionThatLogsIntoDatabase = function () use ($data) {
      //Log $data in the database
    };
    Log::setErrorHandler($functionThatLogsIntoDatabase);
    Log::error($data);
```

The handlers can also use the data that will be provided to the logfile and send it to the Closure.

```
    $data = ["data" => "data"];
    $functionThatLogsIntoDatabase = function ($LogData) {
      //Log $LogData in the DB. Note the LogData is the exact output that will be saved to a file. It is in JSON Format.
    };
    Log::setCriticalHandler($functionThatLogsIntoDatabase);
    Log::critical($data);
```

Logging Levels
--------------

[](#logging-levels)

You can use the following levels of logging as calls:

```
    Log::info([]);
    Log::success([]);
    Log::warn([]);
    Log::error([]);
    Log::critical([]);
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~185 days

Recently: every ~364 days

Total

12

Last Release

1632d ago

Major Versions

0.7.0 → 1.0.02021-11-24

PHP version history (2 changes)0.1PHP &gt;=5.3.0

1.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0c01657f2fe3df0d9bcc9c813d95e422a8afad61a298654d595be447dc86c58?d=identicon)[anekdotes](/maintainers/anekdotes)

![](https://www.gravatar.com/avatar/7919e923b04c280439f2d5aa9eb1daa9135e4e585e45272887ff8839d293b7ca?d=identicon)[Grasseh](/maintainers/Grasseh)

---

Top Contributors

[![Grasseh](https://avatars.githubusercontent.com/u/2159610?v=4)](https://github.com/Grasseh "Grasseh (28 commits)")[![franatieu](https://avatars.githubusercontent.com/u/4522233?v=4)](https://github.com/franatieu "franatieu (2 commits)")

---

Tags

logloggermessages

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[theorchard/monolog-cascade

Monolog extension to configure multiple loggers in the blink of an eye and access them from anywhere

1482.2M9](/packages/theorchard-monolog-cascade)[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)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[bitrix-expert/monolog-adapter

Monolog adapter for Bitrix CMS

6566.3k](/packages/bitrix-expert-monolog-adapter)[dakatsuka/monolog-fluent-handler

Fluentd Handler for Monolog

12480.5k](/packages/dakatsuka-monolog-fluent-handler)

PHPackages © 2026

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