This recipe shows how you can dump all logging data to a file, while still running the job in the Studio. It is particularly useful when debugging large data sets.
The steps for dumping console output to a file from within a job are as follows:
Run the job and view the console output.
Add the following code to
tJava_1
:// redirect the console output to a file from within studio System.setOut(new java.io.PrintStream(new java.io.BufferedOutputStream(new java.io.FileOutputStream(context.cookbookData+"outputData/chapter10/chapter10_jo_0090_consoleOut.txt"))));
Run the job. You will see only the job's start and end messages.
Open the file in the cookbook data directory under
output/chapter10
namedchapter10_jo_0090_consoleOut.txt
. You will see that the logging information has been copied to the file, as shown in the following screenshot: