all Python 3loggingfunction
logging.getLogger()
configuration
Returns a named logger. Loggers form a hierarchy along the dots in their names. Best created at module level: getLogger(__name__).
Syntax
logger = logging.getLogger(name)
The same name always hands back the same object, so you can fetch a logger anywhere instead of threading it through arguments. A record travels up the dotted name hierarchy and the ancestors' handlers fire as well — the usual reason lines appear twice after attaching a handler to both a module logger and the root. A logger's own level defaults to NOTSET, meaning it quietly inherits the level of the nearest ancestor that has one.
Examples
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.info('сообщение из модуля')
import logging
# иерархия
parent = logging.getLogger('app')
child = logging.getLogger('app.db') # наследует настройки parent
See also
Open in the full glossarydocs.python.orgReport an inaccuracy