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

ActiveLibrary

accentinteractive/laravel-logcleaner
====================================

Keep your laravel logs small and tidy.

v1.6.0(1y ago)82252.2k↓16.4%5[1 issues](https://github.com/accentinteractive/laravel-logcleaner/issues)[1 PRs](https://github.com/accentinteractive/laravel-logcleaner/pulls)MITPHPPHP ^7.3|^8.0

Since Apr 4Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/accentinteractive/laravel-logcleaner)[ Packagist](https://packagist.org/packages/accentinteractive/laravel-logcleaner)[ Docs](https://github.com/accentinteractive/laravel-logcleaner)[ RSS](/packages/accentinteractive-laravel-logcleaner/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (17)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 12 support as of 1.6.0.
- Laravel 11 support as of 1.3.0.
- 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');
}
```

Subfolder handling
------------------

[](#subfolder-handling)

From version 1.4.0, files in subfolders are processed as well.

- Trimming: all files in subfolder are trimmed.
- Deleting: in each subfolder, all files except the N most recent ones are deleted. Where N equals config(`logcleaner.log_files_to_keep`).
- Handling of subfolders is set to true by default, but can be overridden by `env('LOGCLEANER_PROCESS_SUBFOLDERS')`

ENV variables
-------------

[](#env-variables)

You can set the following ENV variables in your .env file:

- `LOGCLEANER_LOG_PATH` : The path to your logfile, relative from the root path of your application. If you do not supply `LOGCLEANER_LOG_PATH`, the default Laravel log path will be used. Example value: `storage/custom_logs`.
- `LOGCLEANER_TRIMMING_ENABLED` : Whether to trim log files to a certain number of lines or not. Defaults to `true` if not set in .env.
- `LOGCLEANER_LOG_LINES_TO_KEEP` : The number of lines to keep when trimming files. Defaults to `20000` if not set in .env.
- `LOGCLEANER_DELETING_ENABLED` : Whether to delete older log files or not. Defaults to `true` if not set in .env.
- `LOGCLEANER_LOG_FILES_TO_KEEP` : The number of files to keep when deleting older log files. Defaults to `30` if not set in .env.
- `LOGCLEANER_PROCESS_SUBFOLDERS` : Whether or not to process files in subfolders from the log path. Defaults to `true` if not set in .env.

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

[](#config-settings)

You can pass config settings to modify the behaviour.

- `logcleaner.log_files_to_keep` : the number of log files to keep when deleting old log files. This config setting is overridden by option `--keepfiles`
- `logcleaner.log_lines_to_keep` : the number of lines to leave intact when trimming log files. This config setting is overridden by option `--keeplines`
- `logcleaner.exclude` : an array of filenames to exclude from processing, using wildcards.
- `logcleaner.trimming_enabled` : enables log file trimming. `true` by default.
- `logcleaner.deleting_enabled` : enables old log file deletions. `true` by default.
- `logcleaner.process_subfolders` : whether to include files in subfolders. `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

53

—

FairBetter than 97% of packages

Maintenance67

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 57.9% 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 ~129 days

Recently: every ~68 days

Total

12

Last Release

451d ago

Major Versions

v0.3.0 → v1.0.02021-04-05

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/356020?v=4)[Accent Interactive](/maintainers/accentinteractive)[@accentinteractive](https://github.com/accentinteractive)

---

Top Contributors

[![joostvanveen](https://avatars.githubusercontent.com/u/540294?v=4)](https://github.com/joostvanveen "joostvanveen (22 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (9 commits)")[![accentinteractive](https://avatars.githubusercontent.com/u/356020?v=4)](https://github.com/accentinteractive "accentinteractive (6 commits)")[![niveshsaharan](https://avatars.githubusercontent.com/u/2552126?v=4)](https://github.com/niveshsaharan "niveshsaharan (1 commits)")

---

Tags

accentinteractivelaravel-logcleaner

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[laravel/ui

Laravel UI utilities and presets.

2.7k134.9M601](/packages/laravel-ui)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[sammyjo20/lasso

Lasso - Asset wrangling for Laravel made simple.

355347.9k](/packages/sammyjo20-lasso)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)

PHPackages © 2026

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