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.
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.
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.
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.
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.
Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!
|Talend Training||Mar 25 to Apr 09|
|Talend Training||Mar 28 to Apr 12|
|Talend Training||Apr 01 to Apr 16|
|Talend Training||Apr 04 to Apr 19|
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.
Copyright © 2013 - 2023 MindMajix Technologies