Reputation: 1
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 here
import logging
#create own internal logger (not the root logger)
enter code here
logger = logging.getLogger(name)
enter code here
logger.propagate = False
enter code here
logger.info('hello from helper')
# Propagate: Decides whether a log should be propagated
to the logger's parent
Upvotes: 0
Views: 55
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