How to redirect all output of my console to a file ?

One Star

How to redirect all output of my console to a file ?

Hi everyone , 
Someon can help me plz , I need to redirect all output of my console ( create by Sys.output from tJava) to a file at the end of my process.
I want to see the log in my console too.
Is it possible ?
Highlighted
One Star

Re: How to redirect all output of my console to a file ?

Hi,
You can achieve this by goin to the job properties and in Stats&logs section, define the file output path.
Hope this helps!!
Let me know if you need any more info on this.
Thanks,
Subarna
Community Manager

Re: How to redirect all output of my console to a file ?

You can't do this by editing Talend config I'm afraid. But you can do this with a little Java code in a tJava component at the beginning of your Job.
Below is a bit of code I use to send the output to a file called output.txt on my e: drive
java.io.File outputFile = new java.io.File("e:/output.txt");
System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(outputFile, true), true));
Moderator

Re: How to redirect all output of my console to a file ?

Hi,
Here is a custom component tRedirectOutput which redirect the log message printed on the console to a log file, and then read the header information from the log file and extract the session id.
Please see the related forum:http://community.talend.com:80/t5/Deployment/resolved-save-output-in-run-window-to-txt-file/m-p/8414...
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: How to redirect all output of my console to a file ?

Hi everybody ,
 @xdshi , It appears that the componement not compatible with TOS 5.6
@subarna3103 I did it  before post my squestion, but not work for me.
Moderator

Re: How to redirect all output of my console to a file ?

Hi,
Have you tried this code in tJava?
java.io.File file = new java.io.File("/temp/mylogfile_test.txt");

java.io.PrintStream ps = new java.io.PrintStream(new java.io.FileOutputStream(file));
System.setOut(ps);


Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: How to redirect all output of my console to a file ?

Hi  xdshi
Yes I used this code , but the problem it's that i have the log in myfile but i can't see it in console.
there is'nt solution include log in file + log on console ?
Four Stars

Re: How to redirect all output of my console to a file ?

EDIT :  OH! try to use  System.out.println

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog