0

I was trying to use System.out.println to help with debugging and I found that it wasn't printing to the console. On inspection I found that my program had created 4 output consoles ( one for Java DB processes, one for the DB server, one for debugging the program, and one for program output ). I found my expected println in an unexpected console - the DB server output. I would like to get a handle on these outputs. I expected the System class to have a list field of active output consoles ( printstreams ), something like :

 ArrayList<PrintStream> getActivePrintOutputs() 

But I don't see one. How do I get them?

gristy
  • 487
  • 1
  • 3
  • 7

2 Answers2

1

Normally you have only one active System.out output stream, so there is no reason for the system to maintain a list.

If you want to trace all the PrintStreams created you can use instrumentation to track their creation, or put a break point in the constructor for the class and debug your program.

NOTE: Is is normal for a program to create multiple logs files for different purposes and these might be the PrintStreams you are thinking of.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
1

System has no concept of multiple output streams beyond those specified by out and err, and you can access those by just referencing System.out and System.err respectively.

If there are other consoles or output streams being used, they must have been created by other points in your code (or other points in a library's code that you're using.)

Michael Berry
  • 70,193
  • 21
  • 157
  • 216