Python Logging

import logging
logging.basicConfig(filename='my_logs.log',
                    format='%(asctime)s %(levelname)s [Line:%(lineno)d] [file: %(filename)s]'\
                    '[func: %(funcName)s] [process: %(process)d, %(processName)s]'\
                    '[thread: %(thread)d, %(threadName)s] %(message)s ',
                    filemode='w',
                    datefmt='%d-%m-%Y %H:%M:%S',
                    level=logging.DEBUG)
logging.debug('DEBUG')
logging.info('INFO')
logging.warning('WARNING')
logging.error('ERROR')
logging.critical('CRITICAL')
a = 2
b = 55
print("asdfasf")
asdfasf
x:int = 10 + 10
logging.info(f"The answer is {x}!")
logging.info(f"The answer is {x + a}!")
Back to top