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:
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.
Tip
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.
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:
/
/ 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"))));
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.
Name | Dates | |
---|---|---|
Talend Training | Sep 21 to Oct 06 | View Details |
Talend Training | Sep 24 to Oct 09 | View Details |
Talend Training | Sep 28 to Oct 13 | View Details |
Talend Training | Oct 01 to Oct 16 | View Details |
Ravindra Savaram is a Technical 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.