[英]How to stop Symfony from logging Doctrine's sql queries?
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:我有一个奇怪的问题,当我检查我的
app/log/dev.log
时,我可以看到我的dev.log
中的几乎所有查询都是实时记录的:
[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 ......
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:我不知道为什么会这样,因为当我在
config.yml
中检查 monolog 时,我也在生产模式下运行站点,这就是我所看到的:
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
here's what my config_dev.yml looks like:这是我的 config_dev.yml 的样子:
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?知道这是怎么发生的吗?
You should use prod
env on your production server.您应该在生产服务器上使用
prod
env。 In the prod
env doctrine's logging is disabled by default.在
prod
env 学说中,默认情况下禁用日志记录。
But if you want to disable logging at all (in all environments) you need to set up a config.yml
like that:但是,如果您想完全禁用日志记录(在所有环境中),您需要像这样设置
config.yml
:
doctrine:
dbal:
connections:
conn1:
driver: ...
...
logging: false
profiling: false
Reference: https://symfony.com/doc/current/bundles/DoctrineBundle/configuration.html参考: https : //symfony.com/doc/current/bundles/DoctrineBundle/configuration.html
I encountered a similar issue with dev.log
being generated on prod
environment.我遇到了在
prod
环境中生成dev.log
的类似问题。 I figured out from the log entries that what was causing my issue was a scheduled cron job calling a custom symfony command.我从日志条目中发现导致我出现问题的原因是调度的 cron 作业调用了自定义的 symfony 命令。 Modifying the entry to
app/console
with --env=prod
for my crontab since stopped dev.log
being generated.自从停止生成
dev.log
以来,使用--env=prod
为我的 crontab 修改app/console
的条目。 ie IE
app/console --env=prod custom:command
Must have missed that section of the book :)一定错过了这本书的那部分:)
As I struggled with the same problem and my.log file was increasing its size the straight solution was when running the consumer use the flag --no-debug当我遇到同样的问题并且 my.log 文件正在增加其大小时,直接的解决方案是在运行消费者时使用标志 --no-debug
php bin/console messenger:consume async_email_handler --no-debug
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.