How to get Doctrine to log queries in Symfony2

Full example of config:

config/packages/dev/doctrine.yaml:

doctrine:
    dbal:
        connections:
            default:
                logging: true

If you still don't have monolog, install it: composer require symfony/monolog-bundle and you should start getting all SQL queries in the log file: var/log/dev.log


If you are really sure that you need to log doctrine 2 queries in production then you can set this up in the configs for doctrine.

connections:
        # A collection of different named connections (e.g. default, conn2, etc)
        default:
                # when true, queries are logged to a "doctrine" monolog channel
            logging: true 

http://symfony.com/doc/current/reference/configuration/doctrine.html

And config monolog to log doctrine like explained in the docs: http://symfony.com/doc/current/cookbook/logging/channels_handlers.html

A similar issue can be found at symfony 2.4 can't get the doctrine channel in prod environment