PHPackages                             pfrug/clear-logs - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. pfrug/clear-logs

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pfrug/clear-logs
================

Smart cleanup of Laravel logs by file or content date.

v1.1.0(11mo ago)010MITPHP

Since Mar 20Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/pfrug/clear-logs)[ Packagist](https://packagist.org/packages/pfrug/clear-logs)[ RSS](/packages/pfrug-clear-logs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

ClearLogs
=========

[](#clearlogs)

Artisan command to clean up Laravel log files, with support for both `single` and `daily` log channels. It preserves logs from the last N days, configurable by content date or file modification time.

Features
--------

[](#features)

- Works with `single` and `daily` log channels
- Retains logs by configurable number of days
- Detects dates from log **content**, not just filenames
- Supports `--dry-run` mode (preview changes)
- Optional file name or mtime-based cleanup for daily logs
- Clean truncation of large single log files by full log blocks

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

[](#installation)

Install the package via Composer:

```
composer require pfrug/clear-logs
```

### Optional: Publish configuration

[](#optional-publish-configuration)

```
php artisan vendor:publish --provider="Pfrug\ClearLogs\ClearLogsServiceProvider" --tag="clear-logs-config"
```

This will publish `config/clearlogs.php`.

### Configuration file options

[](#configuration-file-options)

```
return [

    // Number of days to preserve (default: 7)
    'days' => 7,

    // Mode used to determine the file date for daily logs
    // Options: 'name' or 'mtime'
    'evalDateByNameOrMTime' => 'name',
];
```

Usage
-----

[](#usage)

Run the command manually:

```
php artisan log:clear
```

Or preview the result without modifying files:

```
php artisan log:clear --dry-run
```

Override the number of days on the fly:

```
php artisan log:clear --days=10
```

Scheduler Integration
---------------------

[](#scheduler-integration)

To run daily, register the command in your scheduled tasks (`app/Console/Kernel.php`):

```
protected function schedule(Schedule $schedule): void
{
    // Run daily at 2 AM
    $schedule->command('log:clear')->dailyAt('02:00');
}
```

Supported Channels
------------------

[](#supported-channels)

- `single`: The default `laravel.log` file is parsed and truncated. Only complete log blocks newer than the cutoff are retained.
- `daily`: Individual `laravel-YYYY-MM-DD.log` files are deleted if older than the configured threshold.

License
-------

[](#license)

MIT © [P. Frugone](mailto:frugone@gmail.com)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance51

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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

Every ~798 days

Total

2

Last Release

348d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bdea59e3f90698df3c5fa81e8b9f40e0444a32a1bc99270314ef976a90735e70?d=identicon)[frugone](/maintainers/frugone)

---

Top Contributors

[![pfrug](https://avatars.githubusercontent.com/u/5391920?v=4)](https://github.com/pfrug "pfrug (27 commits)")

---

Tags

composerlaravellogsphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pfrug-clear-logs/health.svg)

```
[![Health](https://phpackages.com/badges/pfrug-clear-logs/health.svg)](https://phpackages.com/packages/pfrug-clear-logs)
```

###  Alternatives

[yahnis-elsts/plugin-update-checker

A custom update checker for WordPress plugins and themes. Useful if you can't host your plugin in the official WP repository but still want it to support automatic updates.

2.5k1.5M79](/packages/yahnis-elsts-plugin-update-checker)[2bj/phanybar

Control AnyBar from your php

627.4M2](/packages/2bj-phanybar)[ghanem/rating

Rating system for Laravel

8615.5k](/packages/ghanem-rating)[microman/kirby-column-blocks

Use columns in block fields based on the layout field.

422.5k](/packages/microman-kirby-column-blocks)[bangerkuwranger/magento-2-1-3-category-limit-bug-workaround

Workaround for bug from v2.1.3 that arbitrarily limits indexed products in category to 500

1414.0k](/packages/bangerkuwranger-magento-2-1-3-category-limit-bug-workaround)

PHPackages © 2026

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