gpt4 book ai didi

php - 如何在 Laravel 5 中启用查询日志

转载 作者:行者123 更新时间:2023-11-29 02:56:19 25 4
gpt4 key购买 nike

我一直在搜索如何记录在其中执行的 sql 查询 "laravel/framework": "5.0.*"

但我发现的一切都是关于版本 4 的,还没有找到像这样的 5.0 的任何有效解决方案: Get the query executed in Laravel 3/4How to get the query executed in Laravel 5 ? DB::getQueryLog returning empty arrayhttp://laravelsnippets.com/snippets/log-db-queries

有些描述了如何在 laravel 5 中使用它,但它似乎对我不起作用。我只想将sql日志写入文件。仅此而已,谁能告诉我该怎么做。

非常感谢。

最佳答案

您应该启用 DB::enableQueryLog(); 并且您应该能够在中间件之后获取查询。

这张图片很好地解释了enter image description here

感谢Mattstauffer

关于php - 如何在 Laravel 5 中启用查询日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30435630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com