Answers for "print logger config python"

1

python logging basicconfig stdout

# https://stackoverflow.com/a/14058475
import logging
import sys

root = logging.getLogger()
root.setLevel(logging.DEBUG)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)
Posted by: Guest on May-02-2021
0

python logging basicConfig+time

logging.basicConfig(filename='my_log_file.log', format='%(asctime)s - %(message)s', level=logging.INFO)
Posted by: Guest on December-07-2021

Python Answers by Framework

Browse Popular Code Answers by Language