PHPackages                             niveshsaharan/laravel-logcleaner - 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. niveshsaharan/laravel-logcleaner

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

niveshsaharan/laravel-logcleaner
================================

Keep your laravel logs small and tidy.

1.2.0(2y ago)0767MITPHPPHP ^7.3|^8.0

Since Apr 26Pushed 2y agoCompare

[ Source](https://github.com/niveshsaharan/laravel-logcleaner)[ Packagist](https://packagist.org/packages/niveshsaharan/laravel-logcleaner)[ Docs](https://github.com/accentinteractive/laravel-logcleaner)[ RSS](/packages/niveshsaharan-laravel-logcleaner/feed)WikiDiscussions nivesh Synced today

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

Keep your Laravel logs small and tidy
=====================================

[](#keep-your-laravel-logs-small-and-tidy)

[![Latest Version on Packagist](https://camo.githubusercontent.com/29e34a64132870d5a68cdf30c471cced7b46dbebc6b27950ed00dcb567029c8c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616363656e74696e7465726163746976652f6c61726176656c2d6c6f67636c65616e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/accentinteractive/laravel-logcleaner)[![Build Status](https://camo.githubusercontent.com/6dc33aedc4aea68125f8ebea51499e1e0a28eb63e80e2d03fd4cbfe63ef5f3c5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616363656e74696e7465726163746976652f6c61726176656c2d6c6f67636c65616e65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/accentinteractive/laravel-logcleaner)[![Quality Score](https://camo.githubusercontent.com/b6486675eb8b873afdb0d3223cada8877acd37ed6486f6964500f00f49faeff6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616363656e74696e7465726163746976652f6c61726176656c2d6c6f67636c65616e65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/accentinteractive/laravel-logcleaner)[![Total Downloads](https://camo.githubusercontent.com/c1e84f783b29978e646907dbce61227c1c3cb9e23410ec598f9e52381487181c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616363656e74696e7465726163746976652f6c61726176656c2d6c6f67636c65616e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/accentinteractive/laravel-logcleaner)

Logs can get quite out of hand. This package helps save server space and keep your Laravel log files small.

1. Trim your daily log to a given number of lines do it does not grow huge.
2. Delete old daily logs, only keeping a given number of the latest log files.

- Laravel 10 support as of 1.2.0.
- Laravel 9 support as of 1.1.0.
- Versions before that support Laravel 6, 7, 8.
- [Installation](#installation)
- [Examples](#usage)
- [Config settings](#config-settings)

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

[](#installation)

You can install the package via composer:

```
composer require accentinteractive/laravel-logcleaner
```

Optionally you can publish the config file with:

```
php artisan vendor:publish --provider="Accentinteractive\LaravelLogcleaner\LaravelLogcleanerServiceProvider" --tag="config"

```

Usage
-----

[](#usage)

You can use `logcleaner:run` from the command line or set it as a cron job.

Command line usage;

```
// Get info about the command and options
php artisan logcleaner:run --help

// Trim big log files and delete old log files
php artisan logcleaner:run

// Pass the number of lines to keep when trimming log files. Overrides the config setting.
// This overrides the default set in config
php artisan logcleaner:run --keeplines=10000

// Pass the number of files to keep when deleting old log files. Overrides the config setting.
// This overrides the default set in config
php artisan logcleaner:run --keepfiles=7

// Run without actually cleaning any logs
php artisan logcleaner:run --dry-run
```

Cron job usage, add this to `App\Console\Kernel`:

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('logcleaner:run')->daily()->at('01:00');
}
```

Of course, you can also pass options when defining a cron job.

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('logcleaner:run', ['--keeplines' => 5000, '--keepfiles' => 14])->daily()->at('01:00');
}
```

Config settings
---------------

[](#config-settings)

You can pass config settings to modify the behaviour.

- `log_files_to_keep` : the number of log files to keep when deleting old log files. This config setting is overridden by option `--keepfiles`
- `log_lines_to_keep` : the number of lines to leave intact when trimming log files. This config setting is overridden by option `--keeplines`
- `exclude` : an array of filenames to exclude from processing, using wildcards.
- `trimming_enabled` : enables log file trimming. `true` by default.
- `deleting_enabled` : enables old log file deletions. `true` by default.

You can also pass options directly.

- `--keeplines=2000`
- `--keepfiles=7`
- `--dry-run`

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Joost van Veen](https://github.com/accentinteractive)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

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

1062d ago

### Community

Maintainers

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

---

Top Contributors

[![joostvanveen](https://avatars.githubusercontent.com/u/540294?v=4)](https://github.com/joostvanveen "joostvanveen (13 commits)")[![niveshsaharan](https://avatars.githubusercontent.com/u/2552126?v=4)](https://github.com/niveshsaharan "niveshsaharan (2 commits)")[![accentinteractive](https://avatars.githubusercontent.com/u/356020?v=4)](https://github.com/accentinteractive "accentinteractive (1 commits)")

---

Tags

accentinteractivelaravel-logcleaner

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/niveshsaharan-laravel-logcleaner/health.svg)

```
[![Health](https://phpackages.com/badges/niveshsaharan-laravel-logcleaner/health.svg)](https://phpackages.com/packages/niveshsaharan-laravel-logcleaner)
```

###  Alternatives

[spatie/laravel-uptime-monitor

A powerful, easy to configure uptime monitor

1.1k224.4k8](/packages/spatie-laravel-uptime-monitor)[accentinteractive/laravel-logcleaner

Keep your laravel logs small and tidy.

83244.2k](/packages/accentinteractive-laravel-logcleaner)[ytake/laravel-aspect

Aspect Oriented Programming library for laravel framework, and lumen

140131.0k](/packages/ytake-laravel-aspect)[jackiedo/log-reader

An easy log reader and management tool for Laravel

151365.1k4](/packages/jackiedo-log-reader)[hedii/artisan-log-cleaner

An artisan command to clear laravel log files

4160.8k](/packages/hedii-artisan-log-cleaner)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)

PHPackages © 2026

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