如何停止Symfony记录Doctrine的sql查询? [英] How to stop Symfony from logging Doctrine's sql queries?

查看:106
本文介绍了如何停止Symfony记录Doctrine的sql查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的问题,当我检查我的 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 中检查独白时,我也在生产模式下运行该网站,这是我看到的:

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    

知道这怎么可能吗?

推荐答案

您应该使用 prod 环境在您的生产服务器上。在 prod 中,envctrine的日志记录默认情况下处于禁用状态。

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查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆