import logging logger = logging.getLogger("bot") logger.setLevel(logging.INFO) fh = logging.FileHandler('stable_diffusion_bot.log') fh.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) logger.addHandler(fh) ch = logging.StreamHandler() ch.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) logger.addHandler(ch)