How to stop Symfony from logging Doctrine's sql queries?

前端 未结 2 398
刺人心
刺人心 2021-01-13 06:19

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:



        
相关标签:
2条回答
  • 2021-01-13 07:06

    I encountered a similar issue with dev.log being generated on prod environment. I figured out from the log entries that what was causing my issue was a scheduled cron job calling a custom symfony command. Modifying the entry to app/console with --env=prod for my crontab since stopped dev.log being generated. i.e.

    app/console --env=prod custom:command 
    

    Must have missed that section of the book :)

    0 讨论(0)
  • 2021-01-13 07:14

    You should use prod env on your production server. In the prod env doctrine's logging is disabled by default.

    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
    

    Reference: https://symfony.com/doc/current/bundles/DoctrineBundle/configuration.html

    0 讨论(0)
提交回复
热议问题