logger1=logging.getLogger()
logger1.setLevel(logging.INFO)
fh=logging.FileHandler(file1,mode="w")
logger1.addHandler(fh)
logger1.info("test")
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger1.error("test2")
console = logging.StreamHandler()
console.setLevel(logging.INFO)
logger.addHandler(console)
logger1.addHandler(console)
logger1.info("test3")
fh2 = logging.FileHandler(file2,mode="w")
fh2.setFormatter(formatter)
logger1.addHandler(fh2)
>>> logger1.error("test")
test
>>> logger1.error("test1")
test1
>>> logger1.addHandler(console)
>>> logger1.error("test1")