I'm pretty new to Symfony2, and I'm looking for a way to log SQL queries (including timings) to the same log file as the rest of my application.
From what I can determine from the documentation this should all work out of the box, but after a few hours of trying I can't figure out what I'm doing wrong.
config_dev.yml
monolog:
handlers:
doctrine:
action_level: debug
type: stream
path: %kernel.logs_dir%/%kernel.environment%_doctrine.log
channels: doctrine
config.yml
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
logging: true
profiling: true
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
I get no log file generated at all. My other logging handler works fine (not listed here).
I'm wondering where I've gone wrong here, but also whether this is really the right approach or if I should implement a new class which implements the SQL Logger, as mentioned here: http://vvv.tobiassjosten.net/symfony/logging-doctrine-queries-in-symfony2/
But I've no idea how to plug that in via the configuration/services in order to make it apply project-wide (I don't want to have to call it in every Controller, for example).
Many thanks for any help!