i want to redirect python compiler messages to a file.
for example

if i run a python which has a line


python compiler will give me an error message saying 'syntax error'
how i can fetch this error and write it to a file?

i run it with

./test.py > log.txt

but it will output the error in console.


In linux, you could use

./test.py 2&> log.txt

WoW, thanks alot Gribouillis :D
i greatly appreciated.
but can you please tell me the difference between mine and yours?
what the "2" is doing here?