PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 31, 2022

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

 January 31, 2022     doctrine-orm, php, symfony     No comments   

Issue

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 ......

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

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?


Solution

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



Answered By - Michael Sivolobov
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing