Five Stars

Talend Studio Execution Log?

Hey sorry if that's super obvious but been looking around to find (or set up within a job) a way of putting what's printed in the console at runtime of a job?

 

Need this as planning to automatically run a job via Task Scheduler and want to have a way of finding out how it's run in case anything is wrong.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars

Re: Talend Studio Execution Log?

If you are using the Enterprise Edition, the logs are kept for you and are viewable in the Talend Administration Center. If you are using the Open Source Edition, there is a little trick which will let you re-route the logs to a file of your choosing. Take a look here: https://www.rilhia.com/quicktips/quick-tip-redirect-output-console-file

Rilhia Solutions
9 REPLIES
Twelve Stars

Re: Talend Studio Execution Log?

If you are using the Enterprise Edition, the logs are kept for you and are viewable in the Talend Administration Center. If you are using the Open Source Edition, there is a little trick which will let you re-route the logs to a file of your choosing. Take a look here: https://www.rilhia.com/quicktips/quick-tip-redirect-output-console-file

Rilhia Solutions
Ten Stars

Re: Talend Studio Execution Log?

In addition to the above, you can use your operating system's output redirection when calling the batch file or shell script that executes your job.

(e.g. C:\Path\YourJob.bat > Yourjob.log)
Five Stars

Re: Talend Studio Execution Log?

Hey that's brilliant - thanks!

Just wondering if there's also a way to keep the log stream in app as well instead of re-routing it?

Twelve Stars

Re: Talend Studio Execution Log?

I assume you are talking about my solution. I'm afraid I've not tried that (yet), but just Googled and found this....  https://stackoverflow.com/questions/16237546/writing-to-console-and-text-file

If it works, I'd be interested in hearing about it. Doesn't sound too difficult to test, but I am away from a machine with Talend on at the moment.

 

Rilhia Solutions
Five Stars

Re: Talend Studio Execution Log?

Cheers, I'll play around with this tomorrow and share if I get it to work.
I'm also planning on creating a new log file with today's date so it's easier to document the executions.
Five Stars

Re: Talend Studio Execution Log?

Hey Richard - just an update if you (or anyone else) is interested.

 

I managed to get this to work but there were some problems around loading the correct library for this.

First of all my final code is:

 

java.io.File outputFile = new java.io.File("/Users/george/Documents/testarchive/Log/output"+TalendDate.getDate("yyyyMMdd HHmmss")+".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);

Since the TeeOutputStream function is in the org.apache.commons.io.output library I couldn't get it to work initially.

I couldn't install the library with a jar for some reason (even when selecting it it never appeared in my list of modules).

Instead I added a tLibraryLoad (pointing to the org.apache.commons.io.output) to run, triggering the tJava and et voila!

 

Feel free to update your tip article if you want to and thanks for all your help again!

 

 

Twelve Stars

Re: Talend Studio Execution Log?

Awesome job! I shall remember this. I may add an update to my tutorial referencing your help, if you don't mind

Rilhia Solutions
Five Stars

Re: Talend Studio Execution Log?

I just made one final change so I get the error messages logged in the file as well (last line):

java.io.File outputFile = new java.io.File("/Users/george/Documents/testarchive/Log/output"+TalendDate.getDate("yyyyMMdd HHmmss")+".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);

Note this removes the automatic colourification of errors in the console - everything is printed in black instead.

Twelve Stars

Re: Talend Studio Execution Log?

Nice work @gslokoski. I've added your code to my tutorial. I have credited you using your screen name here. Let me know if you would like me to credit you in some other way or if you want it removed.

https://www.rilhia.com/quicktips/quick-tip-redirect-output-console-file

Rilhia Solutions