pfrug/clear-logs

Removes and truncates old logs.

v1.0 2023-03-20 20:31 UTC

This package is auto-updated.

Last update: 2024-03-20 23:29:06 UTC


README

Laravel comand

Command to remove old logs from Laravel. Supports "single" and "daily" channels

Installation

composer require pfrug/clear-logs

Add the service provider in config/app.php

'providers' => [
    ...
    Pfrug\ClearLogs\ClearLogsServiceProvider::class,
];

Add the configuration file (optionally)

php artisan vendor:publish --provider="Pfrug\ClearLogs\ClearLogsServiceProvider"

Optionally, you may also run php artisan vendor:publish --tag="clear-logs-config" to publish the configuration file in config/clearlogs.php

Usage

Execute artisan command:

php artisan log:clear

Or run as a schedule. Add this code in app/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
    $schedule->command('log:clear')->daily();
}

Configuration

Pblish configuration

php artisan vendor:publish --tag="clear-logs-config"

This command create file configuration options to: config/clearlogs.php

/*
 * Number of days to preserve logs
 * @var int
 */
'days' => 7,

/**
 * Indicates the criteria to evaluate the date of the log file to be deleted.
 * it can be by date of modification or by name of the file ej:"laravel-2022-05-22.log"
 * @var String mit|name
 */
'evalDateByNameOrMTime' => 'name',

License

The MIT License (MIT). Please see License File for more information.