gumbercules/iislogparser

解析 IIS 日志文件的库

0.1.1 2015-09-25 14:02 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:29:55 UTC


README

Code Climate

用于解析 IIS 日志条目的 PHP 类

安装

使用 composer 将其包含到项目中

composer require gumbercules/iislogparser

示例用法

<?php
use Gumbercules\IisLogParser\LogFile;

//create an instance of \SplFileObject to inject into LogFile
$pathToFile = "c:\\some_file.log";
$file = new \SplFileObject($pathToFile);

//create instance of LogFile using \SplFileObject
$logFile = new LogFile($pathToFile);

//you will now have an array of LogEntry objects available via LogFile's getEntries() method
foreach ($logFile->getEntries() as $entry) {
    echo $entry->getRequestMethod();
    //GET
}

条目上的字段

以下字段在 LogEntry 对象上可用。请注意,我根据(我假设的)默认 IIS 日志设置进行了此操作。可能还有其他字段。该库目前尚不支持此功能。

  • \DateTimeImmutable 日期时间 - 通过 getDateTime() 访问
  • string 服务器 IP - 通过 getServerIp() 访问
  • string 服务器端口 - 通过 getServerPort() 访问
  • string 请求方法 - 通过 getRequestMethod() 访问
  • string 请求 URI 根 - 通过 getRequestUri() 访问
  • Array 请求查询 - 存储在数组中的查询字符串键/值对,通过 getRequestQuery() 访问
  • string 客户端 IP - 通过 getClientIp() 访问
  • string 客户端用户名(当启用 Windows 身份验证时,IIS 识别的用户名) - 通过 getClientUsername() 访问
  • string 客户端用户代理 - 通过 getClientUserAgent() 访问
  • int 响应状态码 - 通过 getResponseStatusCode() 访问
  • int 响应状态子码 - 通过 getResponseStatusSubCode() 访问
  • int 响应 WIN32 状态码 - 通过 getResponseStatusWin32Code() 访问 - 请参阅 错误码列表
  • int 所用时间(以毫秒为单位) - 通过 getTimeTaken() 访问