Skip to content

Commit e688568

Browse files
[3.9] bpo-35821: Add an example to Logger.propagate documentation. (GH-29841) (GH-29958)
1 parent 2e36083 commit e688568

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/library/logging.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ is the module's name in the Python package namespace.
8080
If this evaluates to false, logging messages are not passed to the handlers
8181
of ancestor loggers.
8282

83+
Spelling it out with an example: If the propagate attribute of the logger named
84+
`A.B.C` evaluates to true, any event logged to `A.B.C` via a method call such as
85+
`logging.getLogger('A.B.C').error(...)` will [subject to passing that logger's
86+
level and filter settings] be passed in turn to any handlers attached to loggers
87+
named `A.B`, `A` and the root logger, after first being passed to any handlers
88+
attached to `A.B.C`. If any logger in the chain `A.B.C`, `A.B`, `A` has its
89+
`propagate` attribute set to false, then that is the last logger whose handlers
90+
are offered the event to handle, and propagation stops at that point.
91+
8392
The constructor sets this attribute to ``True``.
8493

8594
.. note:: If you attach a handler to a logger *and* one or more of its

0 commit comments

Comments
 (0)