It is often handy to trap program errors in a file. However, errors are sent to
System.err, not System.out. Therefore, you cannot simply trap them by running
java MyProgram > errors.txt
Instead, capture the error stream as
java MyProgram 2> errors.txt
To capture both System.err and System.out in the same file, use
java MyProgram >& errors.txt
This works in bash and the Windows shell.
No comments:
Post a Comment