Yes, you can redirect your code to as many files as you wish as well as to the CLI at the same time. There is a need to introduce a new class to override the existing write method.
Try the following snippet, it works for me:
import sys
class MultiPrinter(object):
def __init__(self, *targets):
self.targets = targets
def write(self, obj):
for f in self.targets:
f.write(obj)
f.flush()
f = open('logs.txt', 'w')
f1 = open('logs1.txt', 'w')
f2 = open('logs2.txt', 'w')
sys_org = sys.stdout
sys.stdout = MultiPrinter(sys_org, f, f1, f2)
print('First Statement.....')
print('Another Statement....')