PHPackages                             uwakmfon1/laravel-logs-cleanup - 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. uwakmfon1/laravel-logs-cleanup

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

uwakmfon1/laravel-logs-cleanup
==============================

A Laravel package for cleaning old log files automatically.

v1.0.1(1mo ago)12MITPHPPHP ^8.4CI passing

Since May 24Pushed 1mo agoCompare

[ Source](https://github.com/Uwakmfon1/laravel-logs-cleanup)[ Packagist](https://packagist.org/packages/uwakmfon1/laravel-logs-cleanup)[ Docs](https://github.com/uwakmfon1/laravel-logs-cleanup)[ GitHub Sponsors](https://github.com/Uwakmfon1)[ RSS](/packages/uwakmfon1-laravel-logs-cleanup/feed)WikiDiscussions main Synced 3w ago

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

Laravel Logs Cleanup
====================

[](#laravel-logs-cleanup)

[![Latest Version on Packagist](https://camo.githubusercontent.com/799f558301c2581cebe5b3d9b482ac022fdfb96a0aa4625efe498d838b336a95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7577616b6d666f6e312f6c61726176656c2d6c6f67732d636c65616e75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/uwakmfon1/laravel-logs-cleanup)[![GitHub Tests Action Status](https://camo.githubusercontent.com/62f157ef83f51183151d1569bec1bc85c37b9698afe30b5b9c3cca3c686a65c3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7577616b6d666f6e312f6c61726176656c2d6c6f67732d636c65616e75702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/uwakmfon1/laravel-logs-cleanup/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/92acc1fbe660976c018d935817ed4b67a6ae8393ac3badd696482acca394e7a7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7577616b6d666f6e312f6c61726176656c2d6c6f67732d636c65616e75702f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/uwakmfon1/laravel-logs-cleanup/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/fcad8db01cdc21e9a34ce60a8a710b691ffb51c7a1e17ccdef549e1fa779bbc2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7577616b6d666f6e312f6c61726176656c2d6c6f67732d636c65616e75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/uwakmfon1/laravel-logs-cleanup)

A lightweight Laravel package for cleaning old entries from storage/logs/laravel.log based on a specified number of days to preserve.

Ideal for large log files containing thousands of lines.

Features
--------

[](#features)

- Cleans only storage/logs/laravel.log
- Preserves recent logs
- Supports dry-run mode
- Creates backup files
- Memory-efficient stream processing
- Safe for large log files

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

[](#installation)

You can install the package via composer:

```
composer require uwakmfon1/laravel-logs-cleanup
```

Publish Configuration
---------------------

[](#publish-configuration)

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-logs-cleanup-config"
```

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

[](#configuration)

File:

```
config/logs-cleanup.php

```

Example:

```
return [

    'log_file' => storage_path('logs/laravel.log'),

    'temp_file' => storage_path('logs/laravel-temp.log'),

    'create_backup' => true,
];
```

Usage
-----

[](#usage)

### Clear entire log file

[](#clear-entire-log-file)

```
php artisan logs:clear
```

### Clear old logs, keep recent days

[](#clear-old-logs-keep-recent-days)

Keep logs from the last 3 days:

```
php artisan logs:clear --except=3
```

Dry Run
-------

[](#dry-run)

Preview cleanup without deleting logs:

```
php artisan logs:clear --dry-run
php artisan logs:clear --except=3 --dry-run
```

How it Works
------------

[](#how-it-works)

The package:

1. Reads laravel.log line-by-line
2. Detects log timestamps
3. Removes entries older than the cutoff date
4. Writes valid logs into a temporary file
5. Replaces the original log safely

This prevents memory exhaustion on large log files.

Supported Log Format
--------------------

[](#supported-log-format)

```
[2026-05-23 10:30:22] local.ERROR: Something happened

```

Example Output
--------------

[](#example-output)

```
Cleaning logs older than 3 days...

Backup created successfully.

Removed: 85,421 lines
Kept: 14,579 lines

Log cleanup completed successfully.

```

Local Package Development
-------------------------

[](#local-package-development)

Inside another Laravel app:

```
composer config repositories.logs-cleaner path ../laravel-logs-cleanup

```

Install Locally:

```
composer require uwakmfon1/laravel-logs-cleanup:dev-main

```

Credits
-------

[](#credits)

- [Uwakmfon1](https://github.com/Uwakmfon1)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance88

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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 ~3 days

Total

2

Last Release

59d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/96330904?v=4)[Uwakmfon Udoh](/maintainers/Uwakmfon1)[@Uwakmfon1](https://github.com/Uwakmfon1)

---

Top Contributors

[![Uwakmfon1](https://avatars.githubusercontent.com/u/96330904?v=4)](https://github.com/Uwakmfon1 "Uwakmfon1 (12 commits)")

---

Tags

laravelUwakmfon1laravel-logs-cleanup

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/uwakmfon1-laravel-logs-cleanup/health.svg)

```
[![Health](https://phpackages.com/badges/uwakmfon1-laravel-logs-cleanup/health.svg)](https://phpackages.com/packages/uwakmfon1-laravel-logs-cleanup)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M48](/packages/spatie-laravel-pdf)[spatie/laravel-health

Monitor the health of a Laravel application

87912.0M177](/packages/spatie-laravel-health)[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

167558.4k1](/packages/keepsuit-laravel-opentelemetry)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.8k](/packages/rawilk-profile-filament-plugin)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

45955.7k](/packages/harris21-laravel-fuse)[tapp/filament-maillog

Filament plugin to view outgoing mail

3070.3k1](/packages/tapp-filament-maillog)

PHPackages © 2026

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