pfrug/clear-logs

删除并截断旧日志。

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

This package is auto-updated.

Last update: 2024-09-21 00:40:56 UTC


README

Laravel命令

用于从Laravel中删除旧日志的命令。支持"单一"和"每日"通道

安装

composer require pfrug/clear-logs

config/app.php中添加服务提供者

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

添加配置文件(可选)

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

可选,您还可以运行php artisan vendor:publish --tag="clear-logs-config"来发布配置文件到config/clearlogs.php

用法

执行 artisan 命令

php artisan log:clear

或作为计划任务运行。在app/Console/Kernel.php中添加此代码

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

配置

发布配置

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

此命令创建配置选项文件到: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',

许可证

MIT许可证(MIT)。请参阅许可证文件获取更多信息。