Issue with using PrintStream

I am trying to create a print stream class and store the errors/console in there, so when errors pop up they are stored in the printstream.

This is because I want to send any errors to a server when they appear. I have code working in eclipse for when an error appears it is stored in the print stream and sent to a server. However when I import it over using a library I made or just copying the code it doesn’t store the console in the print streams.

Does processing have an issue with print streams and byte stream array outputs?

An example of the code I am trying to use:

ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
PrintStream printS = new PrintStream(byteArray);  
System.setErr(pst);
String tester = byteArray.toString(StandardCharsets.UTF_8);

Hi,
i don’t know if it help:

import java.io.PrintStream;
PrintStream pst;
void setup() {
  try { 
    pst = new PrintStream(sketchPath()+"log.txt");  
    System.setOut(pst);
    System.setErr(pst);
    System.out.println("System.out.print...");
  }
  catch(IOException e) {
  }
}

void draw() {
  box((100/0));
  exit();
}

if you run it in processing ide, you will get only the “System.out.println” in the txt file
but if you compile and run you will get the ide console errors too