jkh/apache-log-parser-library

1.0.0 2019-05-03 20:59 UTC

This package is auto-updated.

Last update: 2024-09-04 08:40:05 UTC


README

安装

使用composer

composer require jkh/apache-log-parser-library

用法

简单地实例化类

$parser = new \jkh\ApacheLogParser\ApacheLogParser();

然后解析您的访问日志文件的行

$log_file = '/var/log/apache2/access.log';

$handle = fopen($log_file, "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        $entry = $parser->parse($line);
    }
    fclose($handle);
} else {
    echo "An error occurred: unable to open the file!\n";
}

其中 $entry 对象将持有解析的所有数据。