问题描述
我有一个奇怪的问题,当我检查我的 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 查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)