Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
java.io.File outputFile = new java.io.File("e:/output.txt");
System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(outputFile, true), true));
java.io.File file = new java.io.File("/temp/mylogfile_test.txt");
java.io.PrintStream ps = new java.io.PrintStream(new java.io.FileOutputStream(file));
System.setOut(ps);
@Richard Hall this was very useful for me still 5 years later. If I'm doing this as part of the tPreJob section and I want to email the contents of this "log file" I'm writing console output to later on - how do I close the FileOutputStream for outputFile in another tJava in tPostJob ?
I've always been lazy when using this code and have let the JVM closing close everything. Not ideal, but it works 🙂
What you could try is breaking the above code up onto several statements, then using the globalMap to store a reference to the FileOutputStream. Then in a tPostJob use the globalMap to get a reference to the FileOutputStream in another tJava, then close it there. After that tJava, use a tSendMail to send the file. It would be interesting to see if this works