PHP code example of alkhatibdev / logrotation

1. Go to this page and download the library: Download alkhatibdev/logrotation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alkhatibdev / logrotation example snippets


return [
    'max_months' => env('LOG_ROTATION_MAX_MONTHS', 6),
];

protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        app('logrotator')->rotate();
    })->monthly();
}

Artisan::command('logrotation:rotate', function () {
    app('logrotator')->rotate();
})->monthly();

use AlkhatibDev\LogRotation\LogRotator;

$logRotator = new LogRotator();
$logRotator
    ->setLogFile(storage_path('logs/custom.log')) // Set the log file path to rotate
    ->rotate();
bash
php artisan vendor:publish --tag=logrotation
bash
php artisan schedule:run