PHPackages                             sanjeev-kr/magento2-logrotation - 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. sanjeev-kr/magento2-logrotation

ActiveMagento2-module

sanjeev-kr/magento2-logrotation
===============================

magento 2 extension automatically and manually rotates and gzip-compresses Magento log files in the var/log directory.

2.0.0(today)00MITPHPPHP &gt;=8.0.0

Since Jul 23Pushed todayCompare

[ Source](https://github.com/sanjeev-kr/magento2-logrotation)[ Packagist](https://packagist.org/packages/sanjeev-kr/magento2-logrotation)[ RSS](/packages/sanjeev-kr-magento2-logrotation/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Sanjeev\_Logrotation
====================

[](#sanjeev_logrotation)

A production-ready Magento 2 module that automatically and manually rotates and gzip-compresses Magento log files in the `var/log` directory.

---

Features
--------

[](#features)

- **Automated Daily Log Rotation**: Automatically rotates `.log` files daily at 1:00 AM via Magento cron (`0 1 * * *`).
- **Manual CLI Command**: Trigger log rotation on demand via command line interface (`bin/magento sanjeev:logrotation:rotate`).
- **Gzip Streaming Compression**: Rotates logs to timestamped files (`filename-YYYY-MM-DD-HHMMSS.log`) and compresses them to `.gz` format using chunked streaming for low memory usage.
- **Permission &amp; Ownership Retention**: Preserves file permissions and ownership on newly created empty log files.
- **Security &amp; Safety**: Checks file paths to prevent directory traversal and gracefully handles missing files, file locks, or errors without interrupting ongoing logging or cron execution.
- **Custom Logging**: Operational progress and rotation statistics are logged to `var/log/sanjeev_logrotation.log`.

---

Admin Permissions &amp; Access Control (ACL)
--------------------------------------------

[](#admin-permissions--access-control-acl)

Access to the module's configuration settings in Magento Admin is protected by standard Magento 2 Access Control Lists (ACL).

- **ACL Resource ID**: `Sanjeev_Logrotation::config`
- **Navigation Path in Admin**: `Stores → Configuration → Advanced → Log Rotation`

Only administrator roles granted the `Sanjeev_Logrotation::config` resource (or full Admin access) can view and modify these settings.

---

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

[](#installation)

Follow these steps to install and enable the module:

1. Place module files in the following directory:

    ```
    app/code/Sanjeev/Logrotation
    ```
2. Enable the module:

    ```
    php bin/magento module:enable Sanjeev_Logrotation
    ```
3. Run setup upgrade to register the module:

    ```
    php bin/magento setup:upgrade
    ```
4. Compile dependency injection:

    ```
    php bin/magento setup:di:compile
    ```
5. Flush Magento cache:

    ```
    php bin/magento cache:flush
    ```

---

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

[](#configuration)

Navigate to **Stores → Configuration → Advanced → Log Rotation** in the Magento Admin panel:

- **Enable Log Rotation**:
    - `Yes` *(Default)*: Automated cron job and CLI command will perform log rotation.
    - `No`: Disables log rotation. Cron job will exit immediately without processing any files.

---

How to Use
----------

[](#how-to-use)

### 1. Automated Execution (Cron)

[](#1-automated-execution-cron)

Once enabled, Magento cron will execute the log rotation automatically every day at 1:00 AM according to the schedule defined in `crontab.xml`:

```
0 1 * * *
```

### 2. Manual Execution (CLI Command)

[](#2-manual-execution-cli-command)

To manually trigger log rotation at any time from your server command line, run:

```
php bin/magento sanjeev:logrotation:rotate
```

**Output Example**:

```
Starting log rotation process...
Log rotation process completed successfully.

```

---

Uninstallation
--------------

[](#uninstallation)

To safely disable and remove the module from your Magento store:

1. Disable the module:

    ```
    php bin/magento module:disable Sanjeev_Logrotation
    ```
2. Run setup upgrade:

    ```
    php bin/magento setup:upgrade
    ```
3. Re-compile DI:

    ```
    php bin/magento setup:di:compile
    ```
4. *(Optional)* Remove the module directory from file system:

    ```
    rm -rf app/code/Sanjeev/Logrotation
    ```
5. Flush Magento cache:

    ```
    php bin/magento cache:flush
    ```

---

License &amp; Copyright
-----------------------

[](#license--copyright)

Copyright (c) 2026 Sanjeev Kumar
Licensed under the [MIT License](LICENSE.txt).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20393092?v=4)[Sanjeev Kumar](/maintainers/sanjeev-kr)[@sanjeev-kr](https://github.com/sanjeev-kr)

---

Top Contributors

[![sanjeev-kr](https://avatars.githubusercontent.com/u/20393092?v=4)](https://github.com/sanjeev-kr "sanjeev-kr (1 commits)")

### Embed Badge

![Health badge](/badges/sanjeev-kr-magento2-logrotation/health.svg)

```
[![Health](https://phpackages.com/badges/sanjeev-kr-magento2-logrotation/health.svg)](https://phpackages.com/packages/sanjeev-kr-magento2-logrotation)
```

PHPackages © 2026

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