我有一个奇怪的问题,当我检查我的 app/log/dev.log
时,我可以看到我的 dev.log
中几乎所有的查询都被登录了实时:
I have a weird issue, when I checked my app/log/dev.log
I can see almost all of my queries in my dev.log
being logged in real time:
[2015-01-27 06:57:22] doctrine.DEBUG: SELECT t0.username A ....
[2015-01-27 06:57:23] doctrine.DEBUG: SELECT t0.username A ...
[2015-01-27 06:57:23] doctrine.DEBUG: SELECT s0_.id ......
我不知道为什么会这样,因为当我在 config.yml
中检查 monolog 时,我也在生产模式下运行站点,这就是我看到的:
I have no idea why this is happening, since I am running the site on production mode also when I check monolog in my config.yml
, this is what I see:
monolog:
handlers:
pictures:
type: stream
path: %kernel.logs_dir%/pictures_%kernel.environment%.log
level: info
instagram:
type: stream
path: %kernel.logs_dir%/instagram_%kernel.environment%.log
level: info
这是我的 config_dev.yml 的样子:
here's what my config_dev.yml looks like:
imports:
- { resource: config.yml }
framework:
router: { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
assetic:
use_controller: false
hip_mandrill:
disable_delivery: true
知道这是怎么发生的吗?
any idea how this could be happening?
你应该在你的生产服务器上使用 prod
env.在 prod
环境原则的日志记录在默认情况下是禁用的.
You should use prod
env on your production server. In the prod
env doctrine's logging is disabled by default.
但是,如果您想完全禁用日志记录(在所有环境中),您需要像这样设置 config.yml
:
But if you want to disable logging at all (in all environments) you need to set up a config.yml
like that:
doctrine:
dbal:
connections:
conn1:
driver: ...
...
logging: false
profiling: false
参考:https://symfony.com/doc/current/bundles/DoctrineBundle/configuration.html
这篇关于如何阻止 Symfony 记录 Doctrine 的 sql 查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!