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

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

devuri/logger
=============

A simple PHP Psr Logger library.

v0.2.2(1y ago)13MITPHPPHP ^7.4 || ^8.0CI passing

Since Oct 14Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

PSR Logger
==========

[](#psr-logger)

This package provides a flexible PSR-3 compliant logging solution for your PHP application. It includes a logger with support for all PSR-3 log levels and optional logging to custom files or falling back to `error_log()` when no log file is provided.

Features
--------

[](#features)

- **PSR-3 Compliant**: Supports all PSR-3 log levels (`emergency`, `alert`, `critical`, `error`, `warning`, `notice`, `info`, `debug`).
- **File Logging**: Logs to a specified file, automatically creating the file and necessary directories if they do not exist.
- **Fallback to `error_log()`**: If no log file is specified, the package will fall back to PHP’s built-in `error_log()`.
- **Easy Setup and Use**: A simple static interface (`Log`) to use in your application.

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

[](#installation)

To install the package, you can use Composer:

```
composer require devuri/logger
```

Make sure to include Composer's autoloader in your project:

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

Usage
-----

[](#usage)

### Initialization

[](#initialization)

You can initialize the logger by specifying a log file. If no file is provided, it will fall back to `error_log()`.

```
use Urisoft\Log;
use Urisoft\FileLogger;

// Initialize the logger with a custom log file
$logFile = __DIR__ . '/logs/app.log';
Log::init(new FileLogger($logFile));
```

### Logging Messages

[](#logging-messages)

You can log messages at various levels using the following methods:

```
// Log an informational message
Log::info('Application started successfully.');

// Log an error with context (PSR-3 interpolation)
Log::error('Error occurred: {error}', ['error' => 'Database connection failed']);

// Log a warning message
Log::warning('Low disk space warning.');

// Log a critical error
Log::critical('Critical issue encountered in payment processing.');
```

### Log Levels

[](#log-levels)

The package supports the following log levels:

- `Log::emergency($message, $context = [])`
- `Log::alert($message, $context = [])`
- `Log::critical($message, $context = [])`
- `Log::error($message, $context = [])`
- `Log::warning($message, $context = [])`
- `Log::notice($message, $context = [])`
- `Log::info($message, $context = [])`
- `Log::debug($message, $context = [])`

### Creating the Log File Automatically

[](#creating-the-log-file-automatically)

If the log file or its directories do not exist, the logger will create them automatically:

```
use Urisoft\Log;
use Urisoft\FileLogger;

$logFile = __DIR__ . '/logs/application.log';
Log::init(new FileLogger($logFile));

Log::info('Logging system initialized.');
```

Configuration
-------------

[](#configuration)

### Custom `error_log()`

[](#custom-error_log)

If no log file is provided, the package will fall back to using PHP’s `error_log()` function. You can configure where `error_log()` writes by setting the `error_log` directive in your `php.ini` or using `ini_set()`:

```
// Redirect error_log to a custom file
ini_set('error_log', __DIR__ . '/logs/error.log');

// Initialize logger without a file to fallback to error_log
Log::init(new FileLogger());
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

### Additional Notes:

[](#additional-notes)

- **Error Handling**: If the logger cannot create the log file or write to the specified location, it will throw a `RuntimeException` with a relevant message.
- **Log Rotation**: This package does not include log rotation functionality by default, so you may want to use external tools or another package to handle log rotation.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 92.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 ~0 days

Total

2

Last Release

582d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fd19f958b007ec6588d0a5ca2fe78e107edd652f286b836d36b5d1781d573a5?d=identicon)[devuri](/maintainers/devuri)

---

Top Contributors

[![devuri](https://avatars.githubusercontent.com/u/4777400?v=4)](https://github.com/devuri "devuri (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

psrloglogger

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[analog/analog

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

3451.5M24](/packages/analog-analog)[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

511.0M18](/packages/apix-log)[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)[markrogoyski/simplelog-php

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

2818.1k4](/packages/markrogoyski-simplelog-php)[wa72/simplelogger

Wa72SimpleLogger is a collection of very simple loggers implementing \\Psr\\Log\\LoggerInterface (PSR-3)

13246.6k13](/packages/wa72-simplelogger)

PHPackages © 2026

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