
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Redirect the output from the console to a file
A common question I get when working on client sites is, "How can we save the output from the console without having to copy and paste it?". The console (from Talend DI v6) is shown below.
Unfortunately there isn't a "built-in" way of doing this, but it is very simple to implement this functionality. All you need to do is start your job with a tJava component and add the code below to it.....
java.io.File outputFile = new java.io.File("e:/output.txt"); System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(outputFile, true), true)); |
This code redirects the console output to a file called "output.txt" on the e: drive. Change the file location as required.
Using this trick will ensure that all logging output is sent to the file, but you will no longer see it in the console.
All errors will be shown in the console though.
NOTE: I received a question from @gslokoski about whether the output could be split so that it remains in the console as well as being added to a file. I suggested trying a solution I had found on Google. @gslokoski came back with this solution which I have subsequently tried. It's pretty nice, so I thought I would add it here. All credit to @gslokoski.
java.io.File outputFile = new java.io.File("c:/temp/output.txt"); java.io.FileOutputStream fos = new java.io.FileOutputStream(outputFile); //we will want to print in standard "System.out" and in "file" org.apache.commons.io.output.TeeOutputStream myOut=new org.apache.commons.io.output.TeeOutputStream(System.out, fos); java.io.PrintStream ps = new java.io.PrintStream(myOut, true); //true - auto-flush after println System.setOut(ps); System.setErr(ps); |
You will need to add the commons-io-2.4.jar which comes with Talend. You can do this with a tLibraryLoad component.
- « Previous Replies
-
- 1
- 2
- Next Replies »

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you give a bit more detail about what you are doing and what is happening? If you have the code configured as in the original post, you should be seeing the output in the file and not in the output window.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But those errors will come in talend console,So I want to capture data in console to identify those data truncation errors.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah OK. You need to add some code for the errors. Try this (but change the file paths to your output and error files)...
java.io.File outputFile = new java.io.File("/Users/richardhall/Documents/output.txt"); java.io.File outputFileErr = new java.io.File("/Users/richardhall/Documents/outputErr.txt"); System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(outputFile, true), true)); System.setErr(new java.io.PrintStream(new java.io.FileOutputStream(outputFileErr, true), true));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there any possibility to edit Excel and Xml Files in Talend .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I used to use this and it worked well but not with the current version of Qlik Talend Cloud R2025-01V2. What has changed? Library is now commons-io-2.15.1.jar and it's stopped working

- « Previous Replies
-
- 1
- 2
- Next Replies »