An open API service indexing awesome lists of open source software.

https://github.com/touchdesign/logrotate

Rotate log files.
https://github.com/touchdesign/logrotate

archive filesystem linux-like log logrotate php unix-like

Last synced: 5 months ago
JSON representation

Rotate log files.

Awesome Lists containing this project

README

          

[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg)](https://php.net/)

# Logrotate

Linux like log rotate component written in PHP. For example, if you have a
simple `logfile.log` you can rotate (move) it to `logfile.log.1` and so on.
The source logfile will be truncated. The number of logfiles to keep can
controlled with the `$keep` option.

## Dependencies

* PHP 7.4 or higher

## Install

```shell
composer require touchdesign/logrotate
```

## Usage

```php
$rotate = new RotateWorker(
(new LogfileLoader('/tmp/logfile.log'))
);

// Note: Keep 3 logfiles archived
$rotate->run(3);

$purge = new PurgeWorker(
(new LogfileLoader('/tmp/logfile.log'))
);

$purge->run();
```

For more examples take a look at the example folder in this repository.