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:

  1. Run the job and view the console output.
  2. 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"))));
  3. Run the job. You will see only the job's start and end messages.
  4. Open ...

Get Talend Open Studio Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.