Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I use batchfile.bat >> logfile.txt command in the Windows commandline, it correctly outputs the normal output into the text file, but the Java exceptions get output to the console. Can I make it so that exceptions are written to log file as well?

share|improve this question
up vote 7 down vote accepted

Java exceptions are printed on the standard error stream.

To pipe the standard error stream (file descriptor 2) into a file you can do:

batchfile.bat 2>> errorlog.txt

To pipe both standard error and standard out into the same file:

batchfile.bat >> logfile.txt 2>&1

You can do the same on Unix and Windows

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.