I have a simple piece of code that outputs console text to a text file in Java:

PrintStream out = new PrintStream(new FileOutputStream("test2_output.txt"));
System.setOut(out);

However I require this text file to contain the error messages that is produced in the console but they are not included.

How do I do this?

Edit
Report