gumbercules / iislogparser
解析 IIS 日志文件的库
0.1.1
2015-09-25 14:02 UTC
Requires (Dev)
- phpunit/phpunit: ^4.5
This package is not auto-updated.
Last update: 2024-09-28 15:29:55 UTC
README
用于解析 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()
访问