PHPackages                             pozitronik/yii2-exceptionslogger - 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. pozitronik/yii2-exceptionslogger

ActiveYii2-extension[Logging &amp; Monitoring](/categories/logging)

pozitronik/yii2-exceptionslogger
================================

Exception logger for YII2

1.2.2(3y ago)03.3k1GPL-3.0-or-laterPHPPHP &gt;=8.0CI passing

Since Feb 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/pozitronik/yii2-exceptionslogger)[ Packagist](https://packagist.org/packages/pozitronik/yii2-exceptionslogger)[ RSS](/packages/pozitronik-yii2-exceptionslogger/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (13)Versions (23)Used By (0)

ExceptionsLogger
================

[](#exceptionslogger)

Exceptions logging extension for YII2

[![Build Status](https://github.com/pozitronik/yii2-exceptionslogger/actions/workflows/ci.yml/badge.svg)](https://github.com/pozitronik/yii2-exceptionslogger/actions)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Run

```
php composer.phar require pozitronik/yii2-exceptionslogger "dev-master"

```

or add

```
"pozitronik/yii2-exceptionslogger": "dev-master"

```

to the require section of your `composer.json` file.

Requirements
------------

[](#requirements)

Yii2, PHP &gt;= 8.0

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

[](#configuration)

Run a included migration:

```
yii migrate/up --migrationPath=vendor/pozitronik/yii2-exceptionslogger/migrations

```

It creates the `sys_exceptions` table, which will store exceptions data.

Usage
-----

[](#usage)

Direct logger
-------------

[](#direct-logger)

This extension provides the `SysExceptions::log()` function, that can accept any `Throwable` interface as its first parameter. The exception data will be saved in `sys_exceptions` table (in case of failure, the data will be written into `runtime/exception.log` file).

Example:

```
try {
	$i = $i/0;
} catch (Throwable $t) {
	SysExceptions::log($t);//just silently log exception
	SysExceptions::log(new RuntimeException("Someone tried divide to zero"), false, true);//silently log own exception and mark it as known error
	SysExceptions::log(new RuntimeException("It prohibited by mathematics"), true);//log own exception and throw it
}
```

Default exceptions handler
--------------------------

[](#default-exceptions-handler)

You can use the `pozitronik\sys_exceptions\models\ErrorHandler` class as default application error handler to log all exceptions automatically. Define it in your application config, like:

```
$config = [
    'components' => [
        'errorHandler' => [
            'class' => pozitronik\sys_exceptions\models\ErrorHandler::class,
            'errorAction' => 'site/error'
        ]
    ];
```

How to add custom data to a log record?
=======================================

[](#how-to-add-custom-data-to-a-log-record)

It is possible to add custom string data (e.g. some trace identifier) to every logged error. Configure the `customDataHandler` parameter for the `SysExceptionsModule` module:

```
$config = [
        'modules' => [
            'SysExceptionsModule' => [
                'params' => [
                    'customDataHandler' => static function():string {
                        return Yii::$app->request?->csrfToken;//for example
                    }
                ]
            ],
        ]
    ]
```

The data will be stored in the `custom_data` text field.

License
-------

[](#license)

GNU GPL v3.0

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 98.5% 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 ~59 days

Recently: every ~18 days

Total

20

Last Release

1137d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/76ddc43524bb32eb36568e25b6ae283bc25bb51a4572789997909092145af0f5?d=identicon)[pozitronik](/maintainers/pozitronik)

---

Top Contributors

[![pozitronik](https://avatars.githubusercontent.com/u/2357892?v=4)](https://github.com/pozitronik "pozitronik (135 commits)")[![s1lver](https://avatars.githubusercontent.com/u/4567634?v=4)](https://github.com/s1lver "s1lver (2 commits)")

---

Tags

exceptionsloggeryii2activerecord

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/pozitronik-yii2-exceptionslogger/health.svg)

```
[![Health](https://phpackages.com/badges/pozitronik-yii2-exceptionslogger/health.svg)](https://phpackages.com/packages/pozitronik-yii2-exceptionslogger)
```

###  Alternatives

[lav45/yii2-activity-logger

Tools to store user activity log for Yii2

3456.3k](/packages/lav45-yii2-activity-logger)

PHPackages © 2026

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