CKTIS / Python
logging.getLogger
getLogger devuelve el mismo registrador para un nombre en el intérprete y la raíz si se omite el nombre.
Versión: Python 3.14; repository image, production runtime not attested
Sintaxis
logging.getLogger(name=None)getLogger devuelve el mismo registrador para un nombre en el intérprete y la raíz si se omite el nombre.
Los puntos forman una jerarquía. Con NOTSET se busca el umbral en los ancestros y crear un padre después puede cambiar el parent de un hijo existente.
Fijar ERROR mediante a produce True False True en el ejemplo.
import logging
child=logging.getLogger('ref.sample.leaf')
parent=logging.getLogger('ref.sample')
assert child.parent is parent and logging.getLogger() is logging.getLogger(None)
assert child is logging.getLogger('ref.sample.leaf')
parent.setLevel(logging.ERROR)
assert child.getEffectiveLevel()==logging.ERROR and not child.isEnabledFor(logging.WARNING)
Ejemplos
import logging
a = logging.getLogger("work.sample")
b = logging.getLogger("work.sample")
a.setLevel(logging.ERROR)
print(a is b, b.isEnabledFor(logging.INFO), b.isEnabledFor(logging.ERROR))
Resultado
True False True
Fijar ERROR mediante a produce True False True en el ejemplo.