1

Is there any way to log SQL query execution time with queries? Currently only queries and their params are logged (into doctrine.DEBUG channel).

Symfony 2 (actually 2.0, cannot be updated) and Doctrine 2.2

1 Answer 1

1

From a container aware object, such as your controllers or commands, you can enable logging like this.

$this
    ->get('doctrine')
    ->getConnection()
    ->getConfiguration()
    ->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());

This will set up EchoSQLLogger to do your logging for you, which results in every query and its parameters being printed with echo and var_dump().

Sign up to request clarification or add additional context in comments.

2 Comments

Sadly, this doesn't log the execution time which is what the questioner asked for.
Try with DebugStack as described here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.