Skip to content

Commit 95f75ca

Browse files
[3.10] [doc] Add a section on logging handler configuration order. (GH-101380) (GH-101381)
Co-authored-by: Vinay Sajip <[email protected]>
1 parent 0814a80 commit 95f75ca

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Doc/library/logging.config.rst

+23
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,29 @@ attribute ``baz`` set to ``'bozz'``.
554554
configuration machinery, but set as attribute values as-is.
555555

556556

557+
.. _handler-config-dict-order:
558+
559+
Handler configuration order
560+
"""""""""""""""""""""""""""
561+
562+
Handlers are configured in alphabetical order of their keys, and a configured
563+
handler replaces the configuration dictionary in (a working copy of) the
564+
``handlers`` dictionary in the schema. If you use a construct such as
565+
``cfg://handlers.foo``, then initially ``handlers['foo']`` points to the
566+
configuration dictionary for the handler named ``foo``, and later (once that
567+
handler has been configured) it points to the configured handler instance.
568+
Thus, ``cfg://handlers.foo`` could resolve to either a dictionary or a handler
569+
instance. In general, it is wise to name handlers in a way such that dependent
570+
handlers are configured _after_ any handlers they depend on; that allows
571+
something like ``cfg://handlers.foo`` to be used in configuring a handler that
572+
depends on handler ``foo``. If that dependent handler were named ``bar``,
573+
problems would result, because the configuration of ``bar`` would be attempted
574+
before that of ``foo``, and ``foo`` would not yet have been configured.
575+
However, if the dependent handler were named ``foobar``, it would be configured
576+
after ``foo``, with the result that ``cfg://handlers.foo`` would resolve to
577+
configured handler ``foo``, and not its configuration dictionary.
578+
579+
557580
.. _logging-config-dict-externalobj:
558581

559582
Access to external objects

0 commit comments

Comments
 (0)