From 0a5be4cdbc83edcfdfe7792a9faaab1fbc8cb40e Mon Sep 17 00:00:00 2001 From: Arkalo2 <24898676+Arkalo2@users.noreply.github.com> Date: Mon, 20 Oct 2025 12:59:05 +0200 Subject: [PATCH 1/2] doc(loggin): add documentation for the enabled handler option --- logging.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/logging.rst b/logging.rst index 98a380b82a9..42af229b04c 100644 --- a/logging.rst +++ b/logging.rst @@ -250,6 +250,25 @@ which they are defined: .. _logging-handler-fingers_crossed: + +.. note:: + + You can use the ``enabled`` option to enable or disable a handler depending + on the environment. For example, you can keep logging in ``dev`` and ``prod`` + but disable it in ``staging``: + + .. code-block:: yaml + + monolog: + handlers: + file_log: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + enabled: false # disables the handler + + When ``enabled`` is set to ``false``, the handler is completely ignored. + Handlers that Modify Log Entries ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 996614df23c3cf4b70e1076487109a9f5b0b42a0 Mon Sep 17 00:00:00 2001 From: Arkalo2 <24898676+Arkalo2@users.noreply.github.com> Date: Wed, 22 Oct 2025 12:28:18 +0200 Subject: [PATCH 2/2] Change the block type --- logging.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/logging.rst b/logging.rst index 42af229b04c..fff8dc6b31e 100644 --- a/logging.rst +++ b/logging.rst @@ -251,7 +251,9 @@ which they are defined: .. _logging-handler-fingers_crossed: -.. note:: +.. versionadded:: 3.11.0 + + The ``enabled`` option was introduced in Monolog 3.11.0. You can use the ``enabled`` option to enable or disable a handler depending on the environment. For example, you can keep logging in ``dev`` and ``prod``