How to get Doctrine to log queries in Symfony2

后端 未结 2 1605
半阙折子戏
半阙折子戏 2021-02-20 15:15

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 determ

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-20 15:54

    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

提交回复
热议问题