Skip to content

Instantly share code, notes, and snippets.

@Liad-n
Liad-n / logs.py
Created January 16, 2021 19:56
basic_logging
log_file_path = r'log.log'
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
LOG_FORMAT = "%(levelname)s %(asctime)s - %(message)s"
formatter = logging.Formatter(LOG_FORMAT, datefmt="%Y-%m-%d %H:%M:%S")
file_handler = logging.FileHandler(log_file_path)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)