Dumping the console output to a file from within a job
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.
Getting ready
Open the jo_cook_ch10_0090_consoleToFile
job.
How to do it...
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:
How it works...
When...