Home  >  Blog  >   Talend

Printing out Context and Dumping the Output in Talend

Rating: 5
  1. Share:

Printing out the context

Getting ready

Open the jo_cook_ch10_0080_tContextDump job.

Related Page:: Managing Talend Context Variables

How to do it…

The steps for printing out the context are as follows:

  • Open the Context tab, and you will see a set of context variables.
  • Drag a tContextDump component from the palette.
  • Attach a tLogRow
  • Run the job.

How it works…

tContextDump simply dumps all the context variables defined within the job into a flow that can then be logged via tLogRow.

There’s more…

This component is most useful when running code that has been deployed to a server, because the log information is usually stored in a file. This allows us to check the values of the context variables at the time of execution that would otherwise be hidden from us. This is invaluable for debugging a deployed process that has failed.


Often, contexts contain sensitive information, such as user names and passwords to system resources. If you do not want these to be shown, then ensure that when you dump the data, you tick the Hide Password option.

MindMajix Youtube Channel

MindMajix Talend Training course is designed to make you an expert in developing ETL solutions using Talend platform. Start Learning!

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/ 
 chapter 10/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 named chapter10_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 the Java statement is added to tJava_1, it causes virtually everything that is normally written to the console (System.out.println(), tLogRow) to be directed to a file instead.

There’s more…

The benefit of this technique is that debugging large DATA SETS can be performed in the Studio without the massive performance hit of logging to console and without the need to export the job each time you wish to run it.

It also has the added benefit over writing logging information via a fileOutput component, in that it retains the formatting of tLogRow/tJavaRow and tJava as if it was being output to the console, making the flow of the job logging information easier to understand.

Explore TALEND Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!


Join our newsletter

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
Talend TrainingSep 26 to Oct 11View Details
Talend TrainingSep 30 to Oct 15View Details
Talend TrainingOct 03 to Oct 18View Details
Talend TrainingOct 07 to Oct 22View Details
Last updated: 25 September 2023
About Author

Ravindra Savaram is a Content Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

read more
Try NOW: One-Access by MindMajix