I am running a java program from a OS X 10.8 bash terminal, and are trying to rederect the output it is producing.However, when either running this throug a pipe, or rederecting it to a file, the output is blank, however I see the output in the terminal.To illustrate this:> java program.java13/10/02 14:18:30 WARN some13/10/02 14:18:30 INFO log13/10/02 14:18:30 INFO messages...> java program.java > log> cat log>Can the java program be set up so that it is writing to another stream than stdout, but a stream that still produces output in the terminal. Is such a thing possible?
Pipe not picking up stdout
io redirection;pipe;stdout;output;stderr
There are three standard files open for each program, stdin (standard input), stdout(standard output), and stderr (standard error). Writes to both stdout and stderr is output in the terminal by default.It is a common convention to write errors and log messages to stderr instead of stdout in order to not mix log or error messages with actual program output. You can redirect stderr using 2>, for instance:command 2> log