PHPackages                             radphp/logging - 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. radphp/logging

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

radphp/logging
==============

RadPHP logging component

v0.1.0(10y ago)9271MITPHPPHP &gt;=5.6

Since Apr 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/radphp/logging)[ Packagist](https://packagist.org/packages/radphp/logging)[ RSS](/packages/radphp-logging/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

RadPHP Logging Component
========================

[](#radphp-logging-component)

[![License](https://camo.githubusercontent.com/f88a9ce82d08d0266222e34867f82d5f80b9fb16ecf9c0dfa563d97acf84af76/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7261647068702f6c6f6767696e672e737667)](https://github.com/radphp/logging) [![Total Downloads](https://camo.githubusercontent.com/cf42ca948d01139ab55fa7820ce66fe08189137a9364b1b9a14e6c84e4404576/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7261647068702f6c6f6767696e672e737667)](https://github.com/radphp/logging)

The Logging library provides multiple logging adapters using a simple interface. With the `Logger` class it is possible to send a single message to multiple logging adapters at the same time.

By default you can use File or Null as logging adapters, but you can use any object implementing `Rad\Logging\AdapterInterface` as an adapter for the `Logger` class.

Usage
-----

[](#usage)

You can create new instance adapter and attached to the `Logger` class. An example would be:

```
use Rad\Logging\Logger;
use Rad\Logging\Adapter\FileAdapter;

// Attach single or multiple adapters
$logger = new Logger();

$logger->attachAdapter(new NullAdapter());
$logger->attachAdapter(new FileAdapter('/path/to/file.log'));
// Or attaching your adapter
$logger->attachAdapter(new MyAdapter());

// You can pass message to these log levels
$logger->emergency('Something did not work');
$logger->alert('Something did not work');
$logger->critical('Something did not work');
$logger->error('Something did not work');
$logger->warning('Something did not work');
$logger->notice('Something did not work');
$logger->info('Something did not work');
$logger->debug('Something did not work');
```

The log output is below:

```
09/Apr/2016 11:18:55 UTC [EMERGENCY] Something did not work
09/Apr/2016 11:18:55 UTC [ALERT] Something did not work
09/Apr/2016 11:18:55 UTC [CRITICAL] Something did not work
09/Apr/2016 11:18:55 UTC [ERROR] Something did not work
09/Apr/2016 11:18:55 UTC [WARNING] Something did not work
09/Apr/2016 11:18:55 UTC [NOTICE] Something did not work
09/Apr/2016 11:18:55 UTC [INFO] Something did not work
09/Apr/2016 11:18:55 UTC [DEBUG] Something did not work

```

The log message may contain placeholders. Placeholder names must correspond to keys in the context array. Placeholder names must be delimited with a single opening brace `{` and a single closing brace `}`. There must not be any whitespace between the delimiters and the placeholder name. Placeholder names should be composed only of the characters `A-Z`, `a-z`, `0-9`, underscore `_`, and period `.`. The use of other characters is reserved for future modifications of the placeholders specification.

The following is an example uses placeholder in log message:

```
use Rad\Logging\Logger;
use Rad\Logging\Adapter\FileAdapter;

$logger = new Logger();
$logger->attachAdapter(new FileAdapter('/path/to/file.log'));
$logger->info('User "{user_id}" successfully logged in.', ['user_id' => 2]);
```

### Transactions

[](#transactions)

Transactions store log data temporarily in memory and later on write the data to all adapters.

```
use Rad\Logging\Logger;
use Rad\Logging\Adapter\FileAdapter;

$logger = new Logger();
$logger->attachAdapter(new FileAdapter('/path/to/file.log'));

$logger->begin();
try {
    //Code here
    $logger->commit();
} catch (\Exception $e) {
    $logger->rollback();
    throw $e;
}
```

### Formatter

[](#formatter)

You can use formatter for format log lines or implementing your own formatter. Your formatter must be implemented `Rad\Logging\FormatterInterface`, Default formatter is `LineFormatter`

```
use Rad\Logging\Logger;
use Rad\Logging\Adapter\FileAdapter;

$logger = new Logger();

$fileAdapter = new FileAdapter('/path/to/file.log');
$fileAdapter->setFormatter(new LineFormatter("%time% :: {%level%} :: %message%\n", 'G:i:s T'));
$logger->attachAdapter($fileAdapter);

$logger->emergency('Something did not work');
$logger->alert('Something did not work');
```

The log output with new format:

```
11:18:55 UTC :: {EMERGENCY} :: Something did not work
11:18:55 UTC :: {ALERT} :: Something did not work

```

These variables available for `LineFormatter`:

VariablesDescription%time%Log time%level%Log level%message%Log message

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Total

2

Last Release

3378d ago

### Community

Maintainers

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

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

---

Top Contributors

[![atkrad](https://avatars.githubusercontent.com/u/351364?v=4)](https://github.com/atkrad "atkrad (14 commits)")[![omid](https://avatars.githubusercontent.com/u/45714?v=4)](https://github.com/omid "omid (1 commits)")

---

Tags

loggingRadPHPcomponent

### Embed Badge

![Health badge](/badges/radphp-logging/health.svg)

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

###  Alternatives

[sentry/sentry

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

1.9k240.0M315](/packages/sentry-sentry)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33724.4M84](/packages/rollbar-rollbar)[nelmio/js-logger-bundle

Adds logging of JS errors in your Symfony application

1761.2M](/packages/nelmio-js-logger-bundle)[open-telemetry/api

API for OpenTelemetry PHP.

1938.5M263](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2326.5M316](/packages/open-telemetry-sdk)[markrogoyski/simplelog-php

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

2819.1k4](/packages/markrogoyski-simplelog-php)

PHPackages © 2026

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