I am dealing with a commerical Java API that exposes only the following logging configuration:
cplex.setOut(OutputStream arg0);
I would like to have logging to two streams: a file and the console. Is it possible?
i believe it is.
I would user the apache commons io lib.
For example
FileOutputStream fos = ...;
TeeOutputStream brancher = TeeOutputStream(fos, System.out);
cplex.setOut(brancher);
Write your own OutputStream implementation which delegates calls to the write
methods to two wrapped OutputStreams, one for the console and one for the file.
Easy:
cplex.setOut(new OutputStream() {
public void write(int b) throws IOException {
outputStream1.write(b);
outputStream2.write(b);
}
});