PHPackages                             fyre/log - 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. fyre/log

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

fyre/log
========

A logging library.

v7.0.1(7mo ago)028014MITPHP

Since Oct 28Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreLog)[ Packagist](https://packagist.org/packages/fyre/log)[ RSS](/packages/fyre-log/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (9)Versions (54)Used By (4)

FyreLog
=======

[](#fyrelog)

**FyreLog** is a free, open-source logging library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Loggers](#loggers)
    - [Array](#array)
    - [File](#file)
- [Logging](#logging)

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

[](#installation)

**Using Composer**

```
composer require fyre/log

```

In PHP:

```
use Fyre\Log\LogManager;
```

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

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).
- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).

```
$logManager = new LogManager($container);
```

Default configuration options will be resolved from the "*Log*" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).

**Autoloading**

It is recommended to bind the *LogManager* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(LogManager::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$logManager = $container->use(LogManager::class);
```

Methods
-------

[](#methods)

**Build**

Build a [*Logger*](#loggers).

- `$config` is an array containing configuration options.

```
$logger = $logManager->build($config);
```

[*Logger*](#loggers) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

**Clear**

Clear instances and configs.

```
$logManager->clear();
```

**Get Config**

Get a [*Logger*](#loggers) config.

- `$key` is a string representing the [*Logger*](#loggers) key.

```
$config = $logManager->getConfig($key);
```

Alternatively, if the `$key` argument is omitted an array containing all configurations will be returned.

```
$config = $logManager->getConfig();
```

**Handle**

- `$level` is a string representing the log level .
- `$message` is a string representing the log message.
- `$data` is an array containing data to insert into the message string.
- `$scope` is a string or array representing the log scope, and will default to *null*.

```
$logManager->handle($level, $message, $data, $scope);
```

The supported log levels include: "*emergency*", "*alert*", "*critical*", "*error*", "*warning*", "*notice*", "*info*" and "*debug*".

**Has Config**

Determine whether a [*Logger*](#loggers) config exists.

- `$key` is a string representing the [*Logger*](#loggers) key, and will default to `LogManager::DEFAULT`.

```
$hasConfig = $logManager->hasConfig($key);
```

**Is Loaded**

Determine whether a [*Logger*](#loggers) instance is loaded.

- `$key` is a string representing the [*Logger*](#loggers) key, and will default to `LogManager::DEFAULT`.

```
$isLoaded = $logManager->isLoaded($key);
```

**Set Config**

Set the [*Logger*](#loggers) config.

- `$key` is a string representing the [*Logger*](#loggers) key.
- `$options` is an array containing configuration options.

```
$logManager->setConfig($key, $options);
```

**Unload**

Unload a [*Logger*](#loggers).

- `$key` is a string representing the [*Logger*](#loggers) key, and will default to `LogManager::DEFAULT`.

```
$logManager->unload($key);
```

**Use**

Load a shared [*Logger*](#loggers) instance.

- `$key` is a string representing the [*Logger*](#loggers) key, and will default to `LogManager::DEFAULT`.

```
$logger = $logManager->use($key);
```

[*Logger*](#loggers) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

Loggers
-------

[](#loggers)

You can load a specific logger by specifying the `className` option of the `$config` variable above.

Custom loggers can be created by extending `\Fyre\Log\Logger`, ensuring all below methods are implemented.

**Can Handle**

Determine whether a log level can be handled.

- `$level` is a string representing the log level.
- `$scope` is a string or array representing the log scope, and will default to *null*.

```
$canHandle = $logger->canHandle($level, $scope);
```

This method will return *true* if the `$level` is contained in the `levels` of the *Logger* config (or `levels` is set to *null*), and the `$scope` is contained in `scopes` (or `$scope` is *null* and `scopes` is an empty array, or `scopes` is set to *null*).

**Log**

Log a message.

- `$level` is a string representing the log level.
- `$message` is a string representing the log message.
- `$data` is an array containing data to insert into the message string.

```
$logger->log($level, $message, $data);
```

Array
-----

[](#array)

The Array logger can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Log\Handlers\ArrayLogger`.
    - `levels` is an array containing the levels that should be handled, and will default to *null*.
    - `scopes` is an array containing the scopes that should be handled, and will default to *\[\]*.

```
$container->use(Config::class)->set('Log.array', $options);
```

**Clear**

Clear the log content.

```
$logger->clear();
```

**Read**

Read the log content.

```
$content = $logger->read();
```

### File

[](#file)

The File logger can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Log\Handlers\FileLogger`.
    - `dateFormat` is a string representing the date format, and will default to "*Y-m-d H:i:s*".
    - `levels` is an array containing the levels that should be handled, and will default to *null*.
    - `scopes` is an array containing the scopes that should be handled, and will default to *\[\]*.
    - `path` is a string representing the directory path, and will default to "*/var/log*".
    - `file` is a string representing the file name, and will default *null* (the type of log will be used instead).
    - `suffix` is a string representing the filename suffix, and will default to *null* (or "*-cli*" if running from the CLI).
    - `extension` is a string representing the file extension, and will default to "*log*".
    - `maxSize` is a number representing the maximum file size before log rotation, and will default to *1048576*.

```
$container->use(Config::class)->set('Log.file', $options);
```

Logging
-------

[](#logging)

Generally, logging is done by calling the `handle` method of a *LogManager* instance.

This will call the `canHandle` method of all defined logger configs, and if that returns *true* then the `handle` method will also be called.

The default log levels are shown below (in order of severity).

- `$message` is a string representing the log message.
- `$data` is an array containing data to insert into the message string.
- `$scope` is a string or array representing the log scope, and will default to *null*.

```
$logManager->handle('emergency', $message, $data, $scope);
$logManager->handle('alert', $message, $data, $scope);
$logManager->handle('critical', $message, $data, $scope);
$logManager->handle('error', $message, $data, $scope);
$logManager->handle('warning', $message, $data, $scope);
$logManager->handle('notice', $message, $data, $scope);
$logManager->handle('info', $message, $data, $scope);
$logManager->handle('debug', $message, $data, $scope);
```

There are default placeholders that can also be used in log messages:

- *{post\_vars}* will be replaced with the `$_POST` data.
- *{get\_vars}* will be replaced with the `$_GET` data.
- *{server\_vars}* will be replaced with the `$_SERVER` data.
- *{session\_vars}* will be replaced with the `$_SESSION` data.
- *{backtrace}* will be replaced with the backtrace.

See the [*MessageFormatter::formatMessage*](https://www.php.net/manual/en/messageformatter.formatmessage.php) method for details about message formatting.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance62

Regular maintenance activity

Popularity12

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~28 days

Total

53

Last Release

233d ago

Major Versions

v2.0.1 → v3.02023-07-23

v3.0.14 → v4.02024-10-31

v4.0 → v5.02024-11-02

v5.2.0 → v6.02025-04-02

v6.1.7 → v7.02025-10-28

### Community

Maintainers

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

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (44 commits)")

---

Tags

logloggingphp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fyre-log/health.svg)

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

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k240.0M314](/packages/sentry-sentry)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[illuminate/log

The Illuminate Log package.

6225.0M601](/packages/illuminate-log)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

244.5M182](/packages/api-platform-metadata)[pagemachine/typo3-formlog

Form log for TYPO3

23233.9k7](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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