From e4769d319146cde533429a381a6fa3636203e3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 18 Feb 2024 15:51:05 +0100 Subject: [PATCH] docs: recommend safer way to disable logging (#11269) * Remove trailing newlines * Recommend safer way to disable logging Resetting the middlewares on the configuration object will only work if the connection object hasn't been built from that configuration object yet. Instead, people should find the logger bound to the logging middleware and disable it. --- docs/en/reference/batch-processing.rst | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/en/reference/batch-processing.rst b/docs/en/reference/batch-processing.rst index 12cac934164..ee381bbe5c4 100644 --- a/docs/en/reference/batch-processing.rst +++ b/docs/en/reference/batch-processing.rst @@ -18,14 +18,20 @@ especially what the strategies presented here provide help with. .. note:: - Having an SQL logger enabled when processing batches can have a serious impact on performance and resource usage. - To avoid that you should remove the corresponding middleware. - To remove all middlewares, you can use this line: + Having an SQL logger enabled when processing batches can have a + serious impact on performance and resource usage. + To avoid that, you should use a PSR logger implementation that can be + disabled at runtime. + For example, with Monolog, you can use ``Logger::pushHandler()`` + to push a ``NullHandler`` to the logger instance, and then pop it + when you need to enable logging again. + + With DBAL 2, you can disable the SQL logger like below: + .. code-block:: php getConnection()->getConfiguration()->setMiddlewares([]); // DBAL 3 - $em->getConnection()->getConfiguration()->setSQLLogger(null); // DBAL 2 + $em->getConnection()->getConfiguration()->setSQLLogger(null); Bulk Inserts ------------ @@ -188,6 +194,3 @@ problems using the following approach: Iterating results is not possible with queries that fetch-join a collection-valued association. The nature of such SQL result sets is not suitable for incremental hydration. - - -