██╗ █████╗ ██████╗ █████╗ ██╗ ██╗███████╗██╗
██║ ██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝██║
██║ ███████║██████╔╝███████║██║ ██║█████╗ ██║
██║ ██╔══██║██╔══██╗██╔══██║╚██╗ ██╔╝██╔══╝ ██║
███████╗██║ ██║██║ ██║██║ ██║ ╚████╔╝ ███████╗███████╗
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚══════╝
██╗ ██████╗ ██████╗
██║ ██╔═══██╗██╔════╝
██║ ██║ ██║██║ ███╗
██║ ██║ ██║██║ ██║
███████╗╚██████╔╝╚██████╔╝
╚══════╝ ╚═════╝ ╚═════╝
██████╗██╗ ███████╗ █████╗ ███╗ ██╗███████╗██████╗
██╔════╝██║ ██╔════╝██╔══██╗████╗ ██║██╔════╝██╔══██╗
██║ ██║ █████╗ ███████║██╔██╗ ██║█████╗ ██████╔╝
██║ ██║ ██╔══╝ ██╔══██║██║╚██╗██║██╔══╝ ██╔══██╗
╚██████╗███████╗███████╗██║ ██║██║ ╚████║███████╗██║ ██║
╚═════╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝
Laravel Log Cleaner is a simple package that allows you to clear the content of the laravel.log
file using an
Artisan command. This package is compatible with Laravel versions 7, 8, 9, 10, and 11.
Install the package via Composer by running:
composer require jiordiviera/laravel-log-cleaner
- Laravel 7.x
- Laravel 8.x
- Laravel 9.x
- Laravel 10.x
- Laravel 11.x
This package adds an Artisan command to clear the content of the laravel.log
file. There are two ways to use this
command:
- To clear all logs:
php artisan log:clear
- To clear logs older than a specified number of days:
php artisan log:clear --days=30
Replace 30
with the number of days you want to keep. This will remove all log entries older than the specified number
of days.
Clear all logs:
$ php artisan log:clear
Log file cleared successfully.
Clear logs older than 30 days:
$ php artisan log:clear --days=30
Logs older than 30 days have been removed.
No additional configuration is required. Once the package is installed, the log:clear
command is ready to use.
This package uses Pest for testing. To run the tests, use:
./vendor/bin/pest
Ensure your tests are correctly defined in the tests/
directory.
Contributions are welcome! Feel free to submit Issues or Pull Requests via GitHub.
If you want to contribute:
-
Clone the repository:
git clone https://github.com/jiordiviera/laravel-log-cleaner.git
-
Install dependencies:
composer install
-
Run tests:
./vendor/bin/pest
This package was developed to simplify log file management in Laravel projects. Instead of manually clearing the logs, you can now achieve it with a single command, with the option to selectively remove older logs.
The Laravel Log Cleaner package is open-source software licensed under the MIT License.
Note: Although this package was initially developed with Laravel 11, it is also compatible with earlier versions of Laravel (7, 8, 9, and 10).
For more information, visit the GitHub repository.