user2269707
user2269707

Reputation:

cmd.exe does not redirect errors until the program is finished

I wrote a program with web.py, and used the 2>error.txt to put the errors into a file. This did well on Linux, but on Windows, when an error occurred, nothing was written in the file. I found that on Windows, at normal time, an error occurred, the program which raise the error will be shut down, and the error will be put into the file. But the thing is that in web.py, an error occurred, the program won't be shutdown, so the error won't be written into the file. So what should I do?

Upvotes: 1

Views: 87

Answers (1)

filmor
filmor

Reputation: 32182

In this mailing list entry it is stated that

On Windows, stdout and stderr are unbuffered if they refer to a character device, fully buffered otherwise (Windows doesn't have line buffering; setvbuf(_IOLBF) is equivalent to setvbuf(_IOFBF)).

I'll try to find an additional source for this but this does indeed explain your problem. You can check here:

Disable output buffering

how to shut off output buffering in Python.

Upvotes: 2

Related Questions