I would like to output the stdout and stderr to two different log files. i have tried this code but it only outputs the error to error log , but output is not redirected to runtime.log file.
the code is being run on windows and mostly robocopy is done in the code.
saveerr = sys.stderr
fsock = open('error.log', 'a')
sys.stderr = fsock
saveout = sys.stdout
fsock1 = open('runtime.log', 'a')
sys.stdout = fsock1
the sys.stdout area is not working. please let me know any correction in this code.
here is my entire code
import sys
saveerr = sys.stderr
fsock = open('error.log', 'a')
sys.stderr = fsock
saveout = sys.stdout
fsock1 = open('runtime.log', 'a')
sys.stdout = fsock1
##For site AUCB-NET-01 from source folder AUDC-RSTOR-01 E:\Canberra
exit_code1 = subprocess.call('robocopy \\\\aucb-net-01\\d$ \\\\nasaudc01\\remote_site_sync\\aucb-net-01 /E /MIR /W:2 /R:1', shell=True)
print ("exitcoode1=", exit_code1)
thanks to everyone for reading my post.