Skip to content

Commit e4769d3

Browse files
authored
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.
1 parent 401a0c4 commit e4769d3

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

docs/en/reference/batch-processing.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ especially what the strategies presented here provide help with.
1818

1919
.. note::
2020

21-
Having an SQL logger enabled when processing batches can have a serious impact on performance and resource usage.
22-
To avoid that you should remove the corresponding middleware.
23-
To remove all middlewares, you can use this line:
21+
Having an SQL logger enabled when processing batches can have a
22+
serious impact on performance and resource usage.
23+
To avoid that, you should use a PSR logger implementation that can be
24+
disabled at runtime.
25+
For example, with Monolog, you can use ``Logger::pushHandler()``
26+
to push a ``NullHandler`` to the logger instance, and then pop it
27+
when you need to enable logging again.
28+
29+
With DBAL 2, you can disable the SQL logger like below:
30+
2431
.. code-block:: php
2532
2633
<?php
27-
$em->getConnection()->getConfiguration()->setMiddlewares([]); // DBAL 3
28-
$em->getConnection()->getConfiguration()->setSQLLogger(null); // DBAL 2
34+
$em->getConnection()->getConfiguration()->setSQLLogger(null);
2935
3036
Bulk Inserts
3137
------------
@@ -188,6 +194,3 @@ problems using the following approach:
188194
Iterating results is not possible with queries that
189195
fetch-join a collection-valued association. The nature of such SQL
190196
result sets is not suitable for incremental hydration.
191-
192-
193-

0 commit comments

Comments
 (0)