Python Version : 2.7
I am using the below code to display the logs on console. However, INFO and DEBUG logs are not displayed.
Code
import logging
class LogTest():
def __init__(self):
logger_obj = logging.getLogger('Sample Logger')
console_logger = logging.StreamHandler()
console_logger.setLevel(logging.INFO)
logger_obj.addHandler(console_logger)
logger_obj.info('INFO LOG')
logger_obj.debug('DEBUG LOG')
logger_obj.error('ERROR LOG')
logger_obj.warning('WARNING LOG')
logger_obj.critical('CRITICAL LOG')
if __name__ == '__main__':
log_instance = LogTest()
Output
ERROR LOG
WARNING LOG
CRITICAL LOG
According to python documentation, logs above the set logging level should be displayed. Can anyone explain why this is happening?
Also, How should I enable DEBUG and INFO logs?