PHPackages                             yii2mod/yii2-cron-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. yii2mod/yii2-cron-log

ActiveYii2-extension

yii2mod/yii2-cron-log
=====================

Component for logging cron jobs

1.6(7y ago)2327.6k↓20.8%81MITPHPCI failing

Since Jul 20Pushed 5y ago5 watchersCompare

[ Source](https://github.com/yii2mod/yii2-cron-log)[ Packagist](https://packagist.org/packages/yii2mod/yii2-cron-log)[ RSS](/packages/yii2mod-yii2-cron-log/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (11)Used By (1)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

Yii2 Cron Log Extension
=======================

[](#yii2-cron-log-extension)

Component for logging cron jobs.

[![Latest Stable Version](https://camo.githubusercontent.com/a308493544cebede8f84fc34e2a78ea8d79703323894eb72467151d2517b93d7/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d63726f6e2d6c6f672f762f737461626c65)](https://packagist.org/packages/yii2mod/yii2-cron-log) [![Total Downloads](https://camo.githubusercontent.com/b8a8e8aed00c08078c04271154d35631347cf1de68c243e2f71298899503d253/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d63726f6e2d6c6f672f646f776e6c6f616473)](https://packagist.org/packages/yii2mod/yii2-cron-log) [![License](https://camo.githubusercontent.com/6dd15d0381fea4a5e7896c03bcb16160191606eddb888b5a7a4f93b9c1b640b5/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d63726f6e2d6c6f672f6c6963656e7365)](https://packagist.org/packages/yii2mod/yii2-cron-log) [![Build Status](https://camo.githubusercontent.com/ceebba99d67ea6945469f778579548b6dff1896e5fb8abfa9e22c6dc23612cf8/68747470733a2f2f7472617669732d63692e6f72672f796969326d6f642f796969322d63726f6e2d6c6f672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yii2mod/yii2-cron-log)

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist yii2mod/yii2-cron-log "*"

```

or add

```
"yii2mod/yii2-cron-log": "*"

```

to the require section of your composer.json.

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

[](#configuration)

**Database Migrations**

Before using this extension, we'll also need to prepare the database.

```
php yii migrate/up --migrationPath=@yii2mod/cron/migrations
```

**Error Handler and File Mutex Setup**

Error handler must be defined inside console config, it will be used to log exceptions into database.

> FileMutex implements mutex "lock" mechanism via local file system files.

Add the following code to your console application configuration:

```
'components' => [
    'errorHandler' => [
        'class' => 'yii2mod\cron\components\ErrorHandler',
    ],
    'mutex' => [
        'class' => 'yii\mutex\FileMutex'
    ],
],
```

Usage
-----

[](#usage)

1. To access the list of executed commands, you need to define `CronLogAction` in any controller (for example /modules/admin/SettingsController.php):

```
    public function actions()
    {
        return [
            'cron' => 'yii2mod\cron\actions\CronLogAction',
            // Also you can override some action properties in following way:
            'cron' => [
                'class' => 'yii2mod\cron\actions\CronLogAction',
                'searchClass' => [
                    'class' => 'yii2mod\cron\models\search\CronScheduleSearch',
                    'pageSize' => 10
                ],
                'view' => 'custom name of the view, which should be rendered.'
            ]
        ];
    }
```

> This action is used to view list of executed commands:

2. To log cron actions you should add behavior to all commands that should be logged. In the following example `CronLoggerBehavior` will be log the `index` action.

```
namespace app\commands;

use yii\console\Controller;

/**
 * This command echoes the first argument that you have entered.
 *
 * This command is provided as an example for you to learn how to create console commands.
 *
 */
class HelloController extends Controller
{
    public function behaviors()
    {
        return [
            'cronLogger' => [
                'class' => 'yii2mod\cron\behaviors\CronLoggerBehavior',
                'actions' => ['index']
            ],
            // Example of usage the `MutexConsoleCommandBehavior`
            'mutexBehavior' => [
                'class' => 'yii2mod\cron\behaviors\MutexConsoleCommandBehavior',
                'mutexActions' => ['index'],
                'timeout' => 3600, //default 0
            ]
        ];
    }

    /**
     * This command echoes what you have entered as the message.
     * @param string $message the message to be echoed.
     */
    public function actionIndex($message = 'hello world')
    {
        echo $message . "\n";
    }
}
```

Internationalization
--------------------

[](#internationalization)

All text and messages introduced in this extension are translatable under category 'yii2mod-cron-log'. You may use translations provided within this extension, using following application configuration:

```
return [
    'components' => [
        'i18n' => [
            'translations' => [
                'yii2mod-cron-log' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@yii2mod/cron/messages',
                ],
                // ...
            ],
        ],
        // ...
    ],
    // ...
];
```

Support us
----------

[](#support-us)

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/yii2mod). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 55% 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 ~134 days

Recently: every ~181 days

Total

10

Last Release

2750d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a53a15e1548ce60ee92591e71492a39eaaecfc88eaa1a9d7f353d5c910381de?d=identicon)[disem](/maintainers/disem)

---

Top Contributors

[![dmitry-semenov](https://avatars.githubusercontent.com/u/17027799?v=4)](https://github.com/dmitry-semenov "dmitry-semenov (11 commits)")[![morontt](https://avatars.githubusercontent.com/u/1615692?v=4)](https://github.com/morontt "morontt (2 commits)")[![lutek](https://avatars.githubusercontent.com/u/846598?v=4)](https://github.com/lutek "lutek (2 commits)")[![antonkomarev](https://avatars.githubusercontent.com/u/1849174?v=4)](https://github.com/antonkomarev "antonkomarev (2 commits)")[![mastermind148](https://avatars.githubusercontent.com/u/9828270?v=4)](https://github.com/mastermind148 "mastermind148 (1 commits)")[![philippfrenzel](https://avatars.githubusercontent.com/u/2319890?v=4)](https://github.com/philippfrenzel "philippfrenzel (1 commits)")[![zacksleo](https://avatars.githubusercontent.com/u/3369169?v=4)](https://github.com/zacksleo "zacksleo (1 commits)")

---

Tags

yii2yii2-cron-logyii2-error-handleryii2-extensionyii2-mutexyii2 cron logcron loglogging cron jobs

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/yii2mod-yii2-cron-log/health.svg)

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

PHPackages © 2026

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