Answers for "segrragate same level of error to different log file python"

2

python log to file and console

import logging

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(message)s",
    handlers=[
        logging.FileHandler("debug.log"),
        logging.StreamHandler()
    ]
)
Posted by: Guest on April-07-2020
7

create log in python

logging.basicConfig(filename="logfilename.log", level=logging.INFO)
# Log Creation

logging.info('your text goes here')
logging.error('your text goes here')
logging.debug('your text goes here')
Posted by: Guest on October-28-2020

Code answers related to "segrragate same level of error to different log file python"

Python Answers by Framework

Browse Popular Code Answers by Language