Download the PHP package accentinteractive/laravel-logcleaner without Composer
On this page you can find all versions of the php package accentinteractive/laravel-logcleaner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download accentinteractive/laravel-logcleaner
More information about accentinteractive/laravel-logcleaner
Files in accentinteractive/laravel-logcleaner
Package laravel-logcleaner
Short Description Keep your laravel logs small and tidy.
License MIT
Homepage https://github.com/accentinteractive/laravel-logcleaner
Informations about the package laravel-logcleaner
Keep your Laravel logs small and tidy
Logs can get quite out of hand. This package helps save server space and keep your Laravel log files small.
- Trim your daily log to a given number of lines do it does not grow huge.
- Delete old daily logs, only keeping a given number of the latest log files.
- 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
- Examples
- Config settings
Installation
You can install the package via composer:
Optionally you can publish the config file with:
Usage
You can use logcleaner:run
from the command line or set it as a cron job.
Command line usage;
Cron job usage, add this to App\Console\Kernel
:
Of course, you can also pass options when defining a cron job.
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
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 supplyLOGCLEANER_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 totrue
if not set in .env.LOGCLEANER_LOG_LINES_TO_KEEP
: The number of lines to keep when trimming files. Defaults to20000
if not set in .env.LOGCLEANER_DELETING_ENABLED
: Whether to delete older log files or not. Defaults totrue
if not set in .env.LOGCLEANER_LOG_FILES_TO_KEEP
: The number of files to keep when deleting older log files. Defaults to30
if not set in .env.LOGCLEANER_PROCESS_SUBFOLDERS
: Whether or not to process files in subfolders from the log path. Defaults totrue
if not set in .env.
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
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Joost van Veen
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-logcleaner with dependencies
illuminate/console Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/filesystem Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0