PHP code example of oneseven9955 / logkeeper

1. Go to this page and download the library: Download oneseven9955/logkeeper 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/ */

    

oneseven9955 / logkeeper example snippets


use OneSeven9955\LogKeeper\Config;
use OneSeven9955\LogKeeper\LogKeeper;

$config = new Config(
    path: '/path/to/log/files/*.log',
    timeDelta: \DateInterval::createFromDateString("1 month"),
);

$service = new LogKeeper(
    config: $config,
);

$service->run();

$config = new Config(
    path: '/path/to/log/files/*.log',
    timeDelta: \DateInterval::createFromDateString("1 month"),
    oldPath: 'old/custom.zip', // Default: "old.zip"
);

$config = new Config(
    path: '/path/to/log/files/*.log',
    timeDelta: \DateInterval::createFromDateString("1 month"),
    oldCount: 30,
);

$config = new Config(
    path: '/path/to/log/files/*.log',
    timeDelta: \DateInterval::createFromDateString("1 month"),
    oldCount: 0,
);