PHPackages                             ayaou/command-logger-bundle - 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. ayaou/command-logger-bundle

ActiveSymfony-bundle[Logging &amp; Monitoring](/categories/logging)

ayaou/command-logger-bundle
===========================

This bundle logs all commands executed with console, along with their execution time and errors if applied.

v1.6.0(5mo ago)394[2 issues](https://github.com/ayaou/command-logger-bundle/issues)[1 PRs](https://github.com/ayaou/command-logger-bundle/pulls)MITPHPPHP &gt;=8.1CI passing

Since Mar 28Pushed 5mo ago1 watchersCompare

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

READMEChangelog (8)Dependencies (16)Versions (13)Used By (0)

Command Logger Bundle
=====================

[](#command-logger-bundle)

Overview
--------

[](#overview)

The **Command Logger Bundle** is a Symfony bundle that logs executed console commands. It provides insights into command execution, including arguments, execution time, exit codes, and errors.

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

[](#installation)

Install the bundle via Composer:

```
composer require ayaou/command-logger-bundle
```

Register the bundle in `config/bundles.php` if not automatically added:

```
Ayaou\CommandLoggerBundle\AyaouCommandLoggerBundle::class => ['all' => true],
```

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

[](#configuration)

Add the following configuration in `config/packages/command_logger.yaml`:

```
command_logger:
  enabled: true         # Enable or disable logging (default: true)
  purge_threshold: 100  # Days after which old logs are deleted (e.g., 100 means logs older than 100 days are removed)
  commands:            # List of commands to log if they are not annotated, we can also use wildcards (This can be useful for commands located in third-party bundles)
    - app:example-command
    - app:another-command
    - make:*
```

Usage
-----

[](#usage)

### Enabling Logging on a Command

[](#enabling-logging-on-a-command)

Use configuration `commands` array (if not using attributes) Or:

Use the `CommandLogger` attribute on any Symfony command to enable logging:

```
use Ayaou\CommandLoggerBundle\Attribute\CommandLogger;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'app:example-command')]
#[CommandLogger]
class ExampleCommand extends Command
{
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->writeln('Executing example command...');
        return Command::SUCCESS;
    }
}
```

Entity Structure
----------------

[](#entity-structure)

The logs are stored in the `command_log` table with the following fields:

- `commandName` – Name of the executed command
- `arguments` – Command arguments in JSON format
- `startTime` – Execution start time
- `endTime` – Execution end time
- `exitCode` – Command exit code
- `errorMessage` – Error message if applicable
- `executionToken` – Unique identifier for execution tracking

Show Command Logs
-----------------

[](#show-command-logs)

The `command-logger:show` command displays logged command executions from the `command_log` table. It supports filtering, pagination, and viewing specific entries by ID.

```
bin/console command-logger:show [name] [--limit=LIMIT] [--code=CODE] [--id=ID] [--error] [--success]
```

### Description

[](#description)

This command retrieves and displays command execution logs. By default, it shows the latest 10 entries, ordered by startTime in descending order, in a tabular format. You can filter by command name, exit code, or success/error status, and view a single entry by ID.

The command supports pagination, allowing you to press Enter to view more entries interactively.

### Arguments

[](#arguments)

- name (optional): Filters logs by the command name (e.g., app:example-command).

### Options

[](#options)

- --limit|-l (optional): Specifies the number of entries to show per page (default: 10).
- --code|-c (optional): Filters logs by a specific exit code (e.g., --code=0 for successful commands).
- --id (optional): Displays a single log entry by its ID (e.g., --id=123). When used, no other arguments or options are allowed.
- --error (optional): Filters logs to show only entries with non-zero exit codes (indicating errors). Cannot be used with --success or --code.
- --success (optional): Filters logs to show only entries with an exit code of 0 (indicating success). Cannot be used with --error or --code.

Purging Old Logs
----------------

[](#purging-old-logs)

The bundle includes an automatic mechanism to purge logs older than the configured `purge_threshold`. You can also manually trigger log cleanup using the following command:

```
bin/console command-logger:purge
```

By default, this uses the `purge_threshold` value from the configuration. To override it, specify a custom threshold (in days) with the `--threshold` or `-t` option:

```
bin/console command-logger:purge --threshold=30
```

For example, `--threshold=30` removes logs older than 30 days

License
-------

[](#license)

MIT License

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance58

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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 ~35 days

Recently: every ~62 days

Total

8

Last Release

165d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v1.1.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/0391f29c9cb81e3363d4cbeebdb21350419b5a1a7f92a967d558b3040d9d5e6e?d=identicon)[ayaou](/maintainers/ayaou)

---

Top Contributors

[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (14 commits)")[![ayaou](https://avatars.githubusercontent.com/u/2176494?v=4)](https://github.com/ayaou "ayaou (6 commits)")

---

Tags

logsymfonyloggercommand

###  Code Quality

TestsPHPUnit

Static AnalysisRector

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ayaou-command-logger-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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