patrickriemer/http-log
Composer 安装命令:
composer require patrickriemer/http-log
包简介
HTTP request and response logging to database
README 文档
README
Offers a middleware to automatically log HTTP requests and responses for API endpoints. A model allows manually logging as well. All data will be logged into the database table "http_logs". The following information will be captured:
- Unique request ID (UUID 4)
- Request method
- Request path
- Request URI
- Request header
- Request IP
- Request input (JSON)
- Response status code
- Response header
- Response content (JSON)
- Turnaround time in milliseconds (based on PHP's hrtime, rounded up to the next millisecond)
To enable the request logging for all API requests, add it to the api middleware group in the App\Http\Kernel.php:
use PatrickRiemer\HttpLog\Http\Middleware\LogRequestResponse;
protected $middlewareGroups = [
'api' => [
LogRequestResponse::class,
],
];
The logging is deactivated per default since version 1.1.0. You can enable it in your .env file with the following snippet:
HTTP_LOG_ENABLED=true
The middleware will log the request IP. If you are sitting behind Cloudflare or a similar service that forwards the real IP address, you can specify the header attribute in the environment file that should be used for logging. Example for Cloudflare:
HEADER_REAL_IP=x-real-ip
patrickriemer/http-log 适用场景与选型建议
patrickriemer/http-log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.79k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2023 年 01 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 patrickriemer/http-log 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 patrickriemer/http-log 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2023-01-09