Nathaniel Walthrust
Nathaniel Walthrust

Reputation: 1

My logger will not log one of my log levels.(dealing with logging)

My GitHub is WalthrustN. In a path = my_Python_project/Logging/HelperLog.py, I am trying to figure out why the code doesn't log info levels to the console. Its weird because it logs all other levels + when I import the file with another project. It manages to log the level then. I am confused. Please help. email = [email protected]

https://github.com/WalthrustN/my_Python_project/blob/n/Logging/HelperLog.py

`````````````python``````````````````````````````````

enter code hereimport logging

#create own internal logger (not the root logger) enter code herelogger = logging.getLogger(name) enter code herelogger.propagate = False

enter code herelogger.info('hello from helper')

# Propagate: Decides whether a log should be propagated to the logger's parent

Upvotes: 0

Views: 55

Answers (1)

Hodgson
Hodgson

Reputation: 361

Custom loggers can not be modified with basicConfig().

You can either use the root logger, e.g using logging.warning().

logging.basicConfig(level=logging.DEBUG)
logging.warning('this is a warning')
logging.info('hello from helper')

or add a StreamHandler

logger = logging.getLogger(__name__)
h = logging.StreamHandler()
h.setLevel(logging.DEBUG)
logger.addHandler(h)
logger.warning('this is a warning')
logger.info('hello from helper')

Upvotes: 0

Related Questions