You must redirect STDOUT and STDERR.
command > logfile 2>&1
STDIN is file descriptor #0, STDOUT is file descriptor #1 and STDERR is file descriptor #2.
Just as "command > file" redirects STDOUT to a file, you may also redirect arbitrary file descriptors to each other. The >&
operator redirects between file descriptors. So, 2 >& 1
redirects all STDERR output to STDOUT.
Furthermore, take care to add 2>&1
at the end of the instruction because on Windows, the order of redirection is important as command 2>&1 > logfile
will produce an empty file, as Dawid added in the comments.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…