Gary's Blog

How to config logging output to file and stdio/console with basicConfig() in one line?

import logging

logging.basicConfig(format='[%(asctime)s] [%(levelname)s] %(message)s',
                            datefmt='%Y-%d-%m %I:%M:%S',
                            level=logging.DEBUG,
                            handlers=[logging.FileHandler('app.log'), logging.StreamHandler()])
Exit mobile version