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 ?
7 REPLIES
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
Fifteen Stars

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));
Rilhia Solutions
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 ?
One Star

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

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