Skip to content
Jiordi Viera edited this page Nov 10, 2024 · 3 revisions

Laravel Log Cleaner Wiki

Welcome to the Laravel Log Cleaner wiki! This wiki provides comprehensive documentation about installing, configuring, and using the Laravel Log Cleaner package.

Table of Contents

Installation

Requirements

  • PHP 7.4 or higher
  • Laravel 8.x or higher
  • Composer

Via Composer

composer require jiordiviera/laravel-log-cleaner

Manual Installation

  1. Add the package to your composer.json:
{
    "require": {
       "jiordiviera/laravel-log-cleaner": "^1.0",
    }
}
  1. Run composer update

## Basic Usage

### Using the Command
```bash
php artisan logs:clear

Scheduling the Clean

Add to your App\Console\Kernel:

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

Programmatic Usage

php artisan logs:clear --days=30

Common Issues

Permission Issues

Ensure your web server has write permissions to the log directory:

chmod -R 755 storage/logs
chown -R www-data:www-data storage/logs

Large Log Files

For very large log files, you might want to increase PHP's memory limit in your php.ini:

memory_limit = 512M

Contributing

Development Setup

  1. Fork the repository
  2. Clone your fork
  3. Install dependencies:
composer install
  1. Run tests:
php artisan test

Pull Request Guidelines

  • Fork the repository
  • Create a new branch for your feature
  • Add tests for new functionality
  • Submit a pull request

FAQ

Q: How does the package handle open log files?

A: The package uses file locking to ensure safe operations on open log files.

Q: Can I exclude certain files from cleaning?

A: Yes, use the excluded_files config option or the exclude() method programmatically.

Q: Does it support compressed logs?

A: Yes, the package can handle .gz compressed log files automatically.

Q: How does it handle failed cleaning attempts?

A: The package implements retry mechanisms and logs failures for monitoring.


For more information or support: