1

I have an existing jar file that contains a class I am execution from a batch file as shown below.

java -classpath %CLASSPATH% com.xxx >> LOG_FILE_name 

The class contains lot of System.out and System.err. The System.out is going to the log file mentioned as redirection but the error message is still coming to the console.

How can I redirect System.err to the same log file? I am not in a position to change the code of the classes in the jar file.

Parvez
  • 631
  • 1
  • 6
  • 19

1 Answers1

2

You redirect stderr, like

java -classpath %CLASSPATH% com.xxx >> LOG_FILE_name 2>> ERR_LOG_FILE_name

To use the same log file that would be

java -classpath %CLASSPATH% com.xxx >> LOG_FILE_name 2>&1

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
  • Great! exactly what I was looking for. Found a nice article on io redirection here http://tldp.org/LDP/abs/html/io-redirection.html – Parvez Nov 10 '14 at 06:54