How to redirect standard output to a file

How to redirect standard output to a file
5 (100%) 1 vote

Many times you need to get log details on external files which Talend is not able to redirect or catch using standard Log management, but you know many times error displays on Talend run console but is not caught in error connector. so here is sample code which you can use in your job to redirect error or run console messages to file.

just at the beginning of you job place tJava, and inside a tjava, redirect globally the standard output… insert this code (add buffering if you need):

————————-
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);
————————-

About Umesh

I am Software consultant with approx 7 years of experience mainly in Business Intelligence and data warehousing assignments using Talend. Writing is not my passion but i am doing it to help others. if you have any special case where you want me to demonstrate then please post me.

3 comments on “How to redirect standard output to a file

  1. Umesh, I am a big fan of your articles since I am a newbie to Talend. I am struggling to come up with a solution where I have one centralize Error job to capture the errors of any other jobs. So if my Job A, Job B or Job C throws the error/s it will be picked up by Error Job. I have gone through different posts but no luck as of now. I am in urgent need of such a solution.

    Thanks

    Austin

    1. Thank You Austin!

      You can create one ERROR_JOB, which will use error capture component to catch the errors and move to file/db table. then just drag and drop this(ERROR_JOB) to Job A, B and C to capture the errors. soon i will post the entire workflow.

      Thank you
      Umesh

Leave a Reply to bajrang Cancel reply

Your email address will not be published. Required fields are marked *