Skip to content

Commit

Permalink
docs: recommend safer way to disable logging
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
greg0ire committed Feb 18, 2024
1 parent 401a0c4 commit 8dc49bd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions docs/en/reference/batch-processing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ 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::popHandler()`` as
many times as necessary to remove all handlers from the logger.

With DBAL 2, you can disable the SQL logger like below:

.. code-block:: php
<?php
$em->getConnection()->getConfiguration()->setMiddlewares([]); // DBAL 3
$em->getConnection()->getConfiguration()->setSQLLogger(null); // DBAL 2
Bulk Inserts
Expand Down

0 comments on commit 8dc49bd

Please sign in to comment.