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

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

webfiori/log
============

A lightweight structured logging library for PHP.

v1.0.1(1mo ago)0668↓78.4%[1 issues](https://github.com/WebFiori/log/issues)1MITPHPPHP &gt;=8.1CI passing

Since May 29Pushed 1mo agoCompare

[ Source](https://github.com/WebFiori/log)[ Packagist](https://packagist.org/packages/webfiori/log)[ RSS](/packages/webfiori-log/feed)WikiDiscussions main Synced 1w ago

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

WebFiori Log
============

[](#webfiori-log)

A lightweight structured logging library for PHP with daily file rotation and level filtering.

 [![](https://github.com/WebFiori/log/actions/workflows/php84.yaml/badge.svg?branch=main)](https://github.com/WebFiori/log/actions) [ ![](https://camo.githubusercontent.com/3d26d4c6d774f1e9b8c95d49b414bed5de825954c987657621634260dc2902b3/68747470733a2f2f636f6465636f762e696f2f67682f57656246696f72692f6c6f672f6272616e63682f6d61696e2f67726170682f62616467652e737667) ](https://codecov.io/gh/WebFiori/log) [ ![](https://camo.githubusercontent.com/9a62c275b6cbd0df8ab3359ce222e60165b545b09dc9b1478c6c79e64dc96f6f/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d57656246696f72695f6c6f67266d65747269633d616c6572745f737461747573) ](https://sonarcloud.io/dashboard?id=WebFiori_log) [ ![](https://camo.githubusercontent.com/b87d9133e5ece0ad6f8c311fe0d390a8645fe4c0804906571a053f1ac87f4f3e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f57656246696f72692f6c6f672e7376673f6c6162656c3d6c6174657374) ](https://github.com/WebFiori/log/releases) [ ![](https://camo.githubusercontent.com/a898f45bfe932039d658443eecaef7af2e713370e182dcbd172a2cec86223982/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656266696f72692f6c6f673f636f6c6f723d6c696768742d677265656e) ](https://packagist.org/packages/webfiori/log)

Supported PHP Versions
----------------------

[](#supported-php-versions)

This library requires **PHP 8.1 or higher**.

Build Status[![](https://github.com/WebFiori/log/actions/workflows/php81.yaml/badge.svg?branch=main)](https://github.com/WebFiori/log/actions/workflows/php81.yaml)[![](https://github.com/WebFiori/log/actions/workflows/php82.yaml/badge.svg?branch=main)](https://github.com/WebFiori/log/actions/workflows/php82.yaml)[![](https://github.com/WebFiori/log/actions/workflows/php83.yaml/badge.svg?branch=main)](https://github.com/WebFiori/log/actions/workflows/php83.yaml)[![](https://github.com/WebFiori/log/actions/workflows/php84.yaml/badge.svg?branch=main)](https://github.com/WebFiori/log/actions/workflows/php84.yaml)[![](https://github.com/WebFiori/log/actions/workflows/php85.yaml/badge.svg?branch=main)](https://github.com/WebFiori/log/actions/workflows/php85.yaml)Features
--------

[](#features)

- **Logger interface** — swap implementations without changing application code
- **FileLogger** — daily-rotated log files with structured format
- **Static facade** (`LoggerFacade`) for quick usage without DI
- **Level filtering** — set minimum level (debug, info, warning, error, critical)
- **Structured context** — attach key-value metadata to log entries
- **Zero dependencies** — requires only PHP 8.1+

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

[](#installation)

```
composer require webfiori/log
```

Usage
-----

[](#usage)

### Basic Logging

[](#basic-logging)

```
use WebFiori\Log\FileLogger;
use WebFiori\Log\LogLevel;

$logger = new FileLogger('/var/log/myapp', LogLevel::INFO);

$logger->info('User logged in', ['user_id' => 42, 'ip' => '192.168.1.1']);
$logger->error('Payment failed', ['order_id' => 123, 'reason' => 'timeout']);
$logger->debug('This will be filtered out'); // below INFO threshold
```

**Output** (`/var/log/myapp/app-2026-05-29.log`):

```
[2026-05-29 01:00:00] [INFO] User logged in {"user_id":42,"ip":"192.168.1.1"}
[2026-05-29 01:00:00] [ERROR] Payment failed {"order_id":123,"reason":"timeout"}

```

### Static Facade

[](#static-facade)

```
use WebFiori\Log\LoggerFacade;

LoggerFacade::info('Application started');
LoggerFacade::error('Something went wrong', ['exception' => $e->getMessage()]);
```

### Custom Logger Implementation

[](#custom-logger-implementation)

```
use WebFiori\Log\Logger;

class DatabaseLogger implements Logger {
    public function debug(string $message, array $context = []): void { /* ... */ }
    public function info(string $message, array $context = []): void { /* ... */ }
    public function warning(string $message, array $context = []): void { /* ... */ }
    public function error(string $message, array $context = []): void { /* ... */ }
    public function critical(string $message, array $context = []): void { /* ... */ }
    public function log(string $level, string $message, array $context = []): void { /* ... */ }
}

LoggerFacade::setInstance(new DatabaseLogger());
```

API
---

[](#api)

### `Logger` (interface)

[](#logger-interface)

MethodDescription`debug(string $message, array $context = [])`Log debug message`info(string $message, array $context = [])`Log informational message`warning(string $message, array $context = [])`Log warning message`error(string $message, array $context = [])`Log error message`critical(string $message, array $context = [])`Log critical message`log(string $level, string $message, array $context = [])`Log at specified level### `FileLogger`

[](#filelogger)

MethodDescription`__construct(string $logDir, string $minLevel = 'debug')`Create logger with directory and minimum level`getLogDir(): string`Returns the log directory path`getMinLevel(): string`Returns the current minimum level`setMinLevel(string $level): void`Change the minimum level at runtime### `LogLevel`

[](#loglevel)

ConstantValue`LogLevel::DEBUG``'debug'``LogLevel::INFO``'info'``LogLevel::WARNING``'warning'``LogLevel::ERROR``'error'``LogLevel::CRITICAL``'critical'`### `LoggerFacade`

[](#loggerfacade)

MethodDescription`getInstance(): Logger`Get the default logger`setInstance(Logger $logger): void`Replace the default logger`reset(): void`Destroy the default instanceAll `Logger` methodsDelegates to the default instanceLicense
-------

[](#license)

MIT

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.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

Every ~4 days

Total

2

Last Release

52d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c25e43acaa22b4fb758a710b69c2ab75947a6642925e3bec9c98196b1f2a433?d=identicon)[usernane](/maintainers/usernane)

---

Top Contributors

[![usernane](https://avatars.githubusercontent.com/u/12120015?v=4)](https://github.com/usernane "usernane (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B11.9k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

2041.5M289](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2428.5M356](/packages/open-telemetry-sdk)

PHPackages © 2026

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