akshitarora/dblog
Composer 安装命令:
composer require akshitarora/dblog
包简介
Tool to log heavy database queries in the Laravel application
README 文档
README
A simple Laravel library for devs to log your heavy queries bifurcated by the time taken in your application.
Useful when
- You want to track the queries which are making your application slow.
- You want to monitor the application for the queries which is taking way longer than expected.
- You want to find the slow pages in your application
Features
- Bifurcates the logs datewise so that you can know on what day was your application slow.
- You can also bifurcate the logs based on time taken by the query.
Install
composer require akshitarora/dblog
Add the ServiceProvider in app.php
AkshitArora\DbLog\DbLogServiceProvider::class,
Log structure
[database-name] [time-taken s] SELECT SQL QUERY WHERE PARAMETERS='VALUE' || Path METHOD: /slow/page/here
Configuration
Publish dblog.php configuration file into /config/ for configuration customization:
php artisan vendor:publish --provider=AkshitArora\DbLog\DbLogServiceProvider
Configuration options
<?php
return [
'enabled' => env('DBLOG_ENABLED', env('APP_ENV') === 'local'),
// Only record queries that are slower than the following time
// Unit: seconds
'query_slower_than' => env('DBLOG_QUERY_SLOWER_THAN', 0),
// Only record queries when the DBLOG_TRIGGER is set in the environment,
// or when the trigger HEADER, GET, POST, or COOKIE variable is set.
'trigger' => env('DBLOG_TRIGGER'),
// Log storage location
'log_storage' => env('DBLOG_LOG_STORAGE',env('FILESYSTEM_DRIVER')),
// Time brackets in which the queries are to be bifurcated
'time_brackets' => [2,4,5],
// Set the path in the storage folder where logs need to be stored
'folder_path' => 'dblogs',
];
WARNING
The library writes the slow SQL queries log in the storage folder. Please ensure that the storage folder is not publically accessible if you've kept this library in production.
Special thanks to the package: https://github.com/overtrue/laravel-query-logger
akshitarora/dblog 适用场景与选型建议
akshitarora/dblog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 09 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 akshitarora/dblog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 akshitarora/dblog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-04