Hi Every one,
I’m new to python. I’m trying to divert the complete operational(detail) log in python to a text file but I’m unable to find out how to do it. Could you help me how to achieve it.
ex:
{code}
import sys
a=10
b=20
can you please give us some details? Maybe even some screenshots? At the moment I just can vaguely guess what you want and I don’t even know whether you are working on Linux, Windows, macOS, …?
Sorry for unclear message. I want whole operation to be moved to the txt file. Reason is we created a batch file to run the python code from Control-M. When the job fails we are not able to find the reason for failure. Again we are opening the code manually and executing and finding the error. Attached screenshot for one of the error which I made it to show what I’m looking for. (as the codes are in prod region I could not take screenshot of that). If I made this error move to some external file (txt,log) it will be easy to do RCA and fix the code.
The codes are running in Windows10 Machine
Traceback (most recent call last):
File "<tmp 1>", line 11, in <module>
call_call_bad()
File "<tmp 1>", line 8, in call_call_bad
call_bad()
File "<tmp 1>", line 5, in call_bad
bad()
File "<tmp 1>", line 2, in bad
1/0 # Whoops!
ZeroDivisionError: division by zero
This is usually enough. Python does not keep track of every line of code executed because it would be very large to hold in memory and impact performance. I never felt the need for it, either: the amount of output would be too huge for any non-trivial program that it would be unreadable. When you want to debug a program, you have two main options: