Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/overtrue/laravel-query-logger
:pencil: A dev tool to log all queries for laravel application.
https://github.com/overtrue/laravel-query-logger
laravel logger query query-logger
Last synced: 3 days ago
JSON representation
:pencil: A dev tool to log all queries for laravel application.
- Host: GitHub
- URL: https://github.com/overtrue/laravel-query-logger
- Owner: overtrue
- Created: 2017-09-05T14:59:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-08T21:25:04.000Z (3 months ago)
- Last Synced: 2025-01-02T13:04:02.277Z (10 days ago)
- Topics: laravel, logger, query, query-logger
- Language: PHP
- Size: 51.8 KB
- Stars: 408
- Watchers: 10
- Forks: 50
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- favorite-link - 📝 开发工具,用于记录 laravel 应用程序的所有查询。
README
Laravel Query Logger
:pencil: A dev tool to log all queries for Laravel application.
[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue)
## Installing
```shell
$ composer require overtrue/laravel-query-logger -vvv
```Laravel Query Logger will be enabled when `LOG_QUERY` is `true`.
## Usage
```shell
$ tail -f ./storage/logs/laravel.log
```[2017-09-05 14:52:14] local.DEBUG: [800μs] select count(*) as aggregate from `discussions` where `discussions`.`deleted_at` is null | GET: http://laravel.app/discussions
[2017-09-05 14:52:14] local.DEBUG: [1.07ms] select * from `discussions` where `discussions`.`deleted_at` is null order by `is_top` desc, `created_at` desc limit 15 offset 0 | GET: http://laravel.app/discussions
[2017-09-05 14:52:14] local.DEBUG: [3.63s] select `tags`.*, `taggables`.`taggable_id` as `pivot_taggable_id`, `taggables`.`tag_id` as `pivot_tag_id` from `tags` inner join `taggables` on `tags`.`id` = `taggables`.`tag_id` where `taggables`.`taggable_id` in ('1', '2', '3', '4', '5', '6', '7', '8') and `taggables`.`taggable_type` = 'App\\Models\\Discussion' order by `order_column` asc | GET: http://laravel.app/discussions
[2017-09-05 14:52:14] local.DEBUG: [670μs] select * from `users` where `users`.`id` in ('1', '2', '4') and `users`.`deleted_at` is null | GET: http://laravel.app/discussions
...
### ConfigurationYou can also control whether to log a query via the configuration file:
*config/logging.php:*
```php
return [
//...
'query' => [
'enabled' => env('LOG_QUERY', env('APP_ENV') === 'local'),
// Only record queries that are slower than the following time
// Unit: milliseconds
'slower_than' => 0,
// Only record queries when the QUERY_LOG_TRIGGER is set in the environment,
// or when the trigger HEADER, GET, POST, or COOKIE variable is set.
'trigger' => env('QUERY_LOG_TRIGGER'),// Except record queries
'except' => [
// '*_telescope_*',
],
// Log Channel
'channel' => 'stack',
],
];
```## :heart: Sponsor me
[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue)
如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue)
## Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
[![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/overtrue)
## PHP 扩展包开发
> 想知道如何从零开始构建 PHP 扩展包?
>
> 请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)## License
MIT