Please find attached job design.
We are trying to print console log to the txt file. Here is the code which we have written in tJAva_1.
File fileobj = new File("D:/Talend/" + jobName + TalendDate.getDate("DDMMYYYY-HHmmss") +".txt");
PrintStream obj = new PrintStream(new BufferedOutputStream(new FileOutputStream(fileobj)));
This code is logging only error information to the text file, e.g. error thrown from stored procedure. No other information is getting logged in to the text file.
We are basically logging steps in our job using tJavaRow component. We are expecting information from tJavaRow component to get written in to text file.
Here is the code which we have written in our tJavaRow component
System.out.println("Going to Process AgentId " + input_row.AgentID);
Solved! Go to Solution.
Are you sure the Job is running? Can you show us your errors? I suspect that they are compilation errors, in which case you will not see any data as the job will not actually run.
I do something very similar to this, but I split the output to be written to two different files as well as keeping it in the console. I do this using a tLibraryLoad component to import the commons-io-2.4.jar and then use the code below...
java.io.File outputFile = new java.io.File("c:/temp/output.txt"); java.io.FileOutputStream fosOut = new java.io.FileOutputStream(outputFile); org.apache.commons.io.output.TeeOutputStream myOut = new org.apache.commons.io.output.TeeOutputStream(System.out, fosOut); java.io.PrintStream psOut = new java.io.PrintStream(myOut, true); //true - auto-flush after println java.io.File errorFile = new java.io.File("c:/temp/error.txt"); java.io.FileOutputStream fosErr = new java.io.FileOutputStream(errorFile); org.apache.commons.io.output.TeeOutputStream myErr=new org.apache.commons.io.output.TeeOutputStream(System.err, fosErr); java.io.PrintStream psErr = new java.io.PrintStream(myErr, true); //true - auto-flush after println System.setOut(psOut); System.setErr(psErr);
what is the issue ? Asuming you get an empty file log file ?
May you forget to call a close on your BufferedOutPutStream ?
Consider to put a reference to you BufferedOutPutStream to the globalMap and call it with close() at the end of the job.
Use your PrintStream with the fileObj instead of the BufferedOutputStream
Talend named a Leader.
Kickstart your first data integration and ETL projects.
Watch the recorded webinar!
Learn how to do cool things with Context Variables
Find out how to migrate from one database to another using the Dynamic schema
Pick up some tips and tricks with Context Variables