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

93 记录 Leave a Comment
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()])

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *