PHPackages                             azurre/php-simple-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. azurre/php-simple-logger

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

azurre/php-simple-logger
========================

Simple PSR-3 logger

1.1.0(4y ago)04.1k1MITPHPPHP &gt;=5.6.0

Since Feb 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/azurre/simplelog-php)[ Packagist](https://packagist.org/packages/azurre/php-simple-logger)[ Docs](https://github.com/azurre/php-simple-logger/)[ RSS](/packages/azurre-php-simple-logger/feed)WikiDiscussions master Synced yesterday

READMEChangelog (7)Dependencies (3)Versions (8)Used By (1)

Simple Logger PSR-3 logger
==========================

[](#simple-logger-psr-3-logger)

Simple Logger is a powerful PSR-3 logger for PHP that is simple to use.

Features
--------

[](#features)

- Power and Simplicity
- PSR-3 logger interface
- Multiple handlers support
- Multiple log level severities
- Log channels
- Process ID logging
- Custom log messages
- Custom contextual data
- Exception logging

Setup
-----

[](#setup)

```
$ composer require azurre/php-simple-logger
```

Usage
-----

[](#usage)

### Simple 20-Second Getting-Started Tutorial

[](#simple-20-second-getting-started-tutorial)

```
use \Azurre\Component\Logger;
use \Azurre\Component\Logger\Handler\File;

$logger = new Logger();
$logger->info('Simple Logger really is simple.');
```

That's it! Your application is logging! Log file will be "default.log".

### Extended Example

[](#extended-example)

```
use \Azurre\Component\Logger;
use \Azurre\Component\Logger\Handler\File;

$logfile = '/var/log/events.log';
$channel = 'billing';
$logger  = new Logger($channel);
$logger->setHandler(new File($logfile));

$logger->info('Begin process that usually fails.', ['process' => 'invoicing', 'user' => $user]);

try {
    invoiceUser($user); // This usually fails
} catch (\Exception $e) {
    $logger->error('Billing failure.', ['process' => 'invoicing', 'user' => $user, 'exception' => $e]);
}
```

Logger output

```
2017-02-13 00:35:55.426630  [info]  [billing] [pid:17415] Begin process that usually fails. {"process":"invoicing","user":"bob"}  {}
2017-02-13 00:35:55.430071  [error] [billing] [pid:17415] Billing failure.  {"process":"invoicing","user":"bob"}  {"message":"Could not process invoice.","code":0,"file":"/path/to/app.php","line":20,"trace":[{"file":"/path/to/app.php","line":13,"function":"invoiceUser","args":["mark"]}]}

```

### Log Output

[](#log-output)

Log lines have the following format:

```
YYYY-mm-dd HH:ii:ss.uuuuuu  [loglevel]  [channel]  [pid:##]  Log message content  {"Optional":"JSON Contextual Support Data"}  {"Optional":"Exception Data"}

```

Log lines are easily readable and parsable. Log lines are always on a single line. Fields are tab separated.

### Log Levels

[](#log-levels)

'Simple Logger has eight log level severities based on [PSR Log Levels](http://www.php-fig.org/psr/psr-3/#psrlogloglevel).

```
$logger->debug('Detailed information about the application run.');
$logger->info('Informational messages about the application run.');
$logger->notice('Normal but significant events.');
$logger->warning('Information that something potentially bad has occured.');
$logger->error('Runtime error that should be monitored.');
$logger->critical('A service is unavailable or unresponsive.');
$logger->alert('The entire site is down.');
$logger->emergency('The Web site is on fire.');
```

By default all log levels are logged. The minimum log level can be changed in two ways:

- Optional constructor parameter
- Setter method at any time

```
use \Psr\Log\LogLevel;
use \Azurre\Component\Logger;

// Optional constructor Parameter (Only error and above are logged [error, critical, alert, emergency])
$logger = new Logger($channel, LogLevel::ERROR);

// Setter method (Only warning and above are logged)
$logger->setLogLevel(LogLevel::WARNING);
```

### Contextual Data

[](#contextual-data)

'Simple Logger enables logging best practices to have general-use log messages with contextual support data to give context to the message.

The second argument to a log message is an associative array of key-value pairs that will log as a JSON string, serving as the contextual support data to the log message.

```
// Add context to a Web request.
$log->info('Web request initiated', ['method' => 'GET', 'endpoint' => 'user/account', 'queryParameters' => 'id=1234']);

// Add context to a disk space warning.
$log->warning('Free space is below safe threshold.', ['volume' => '/var/log', 'availablePercent' => 4]);
```

### Logging Exceptions

[](#logging-exceptions)

Exceptions are logged with the contextual data using the key *exception* and the value the exception variable.

```
catch (\Exception $e) {
    $logger->error('Something exceptional has happened', ['exception' => $e]);
}
```

### Log Channels

[](#log-channels)

Think of channels as namespaces for log lines. If you want to have multiple loggers or applications logging to a single log file, channels are your friend.

Channels can be set in two ways:

- Constructor parameter
- Setter method at any time

```
// Constructor Parameter
$channel = 'router';
$logger  = new Logger($channel);

// Setter method
$logger->setChannel('database');
```

Unit Tests
----------

[](#unit-tests)

```
$ cd tests
$ phpunit
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 63.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 ~318 days

Recently: every ~261 days

Total

6

Last Release

1785d ago

Major Versions

v0.1.2 → 1.0.02018-12-08

PHP version history (2 changes)v0.1.0PHP &gt;=7.0.0

1.1.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f5bbeafb1d06ec9c1ba940980a19a3fd3902cef3499a446726677986be73b0ec?d=identicon)[a.milenin](/maintainers/a.milenin)

---

Top Contributors

[![markrogoyski](https://avatars.githubusercontent.com/u/10004372?v=4)](https://github.com/markrogoyski "markrogoyski (19 commits)")[![azurre](https://avatars.githubusercontent.com/u/2183975?v=4)](https://github.com/azurre "azurre (11 commits)")

---

Tags

logpsr-3logginglogger

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/azurre-php-simple-logger/health.svg)

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

###  Alternatives

[monolog/monolog

Sends your logs to files, sockets, inboxes, databases and various web services

21.4k964.9M7.0k](/packages/monolog-monolog)[analog/analog

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

3451.5M24](/packages/analog-analog)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[apix/log

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

511.0M18](/packages/apix-log)[markrogoyski/simplelog-php

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

2818.1k4](/packages/markrogoyski-simplelog-php)[amphp/log

Non-blocking logging for PHP based on Amp, Revolt, and Monolog.

402.6M70](/packages/amphp-log)

PHPackages © 2026

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