1. Go to this page and download the library: Download cesargb/php-log-rotation 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/ */
cesargb / php-log-rotation example snippets
use Cesargb\Log\Rotation;
use Cesargb\Log\Exceptions\RotationFailed;
$rotation = new Rotation();
$rotation
->compress() // Optional, compress the file after rotated. Accept level compression argument.
->files(30) // Optional, files are rotated 30 times before being removed. Default 366
->minSize(1024) // Optional, are rotated when they grow bigger than 1024 bytes. Default 0
->truncate() // Optional, truncate the original log file in place after creating a copy, instead of moving the old log file.
->then(function ($filenameTarget, $filenameRotated) {}) // Optional, to get filename target and original filename
->catch(function (RotationFailed $exception) {}) // Optional, to catch a exception in rotating
->finally(function ($message, $filenameTarget) {}) // Optional, this method will be called when the process has finished
->rotate('file.log');
use Cesargb\Log\Rotation;
use Cesargb\Log\Exceptions\RotationFailed;
$rotation = new Rotation([
'files' => 1,
'compress' => true, // Set level compression or true to default level. Default false
'min-size' => 10,
'truncate' => false,
'then' => function ($filename) {},
'catch' => function (RotationFailed $exception) {},
'finally' => function ($message, $filename) {},
]);
$rotation->rotate('file.log');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.