简体   繁体   中英

How to capture nullpointerexception,ftp connection issues via a log/output file talend job

在此处输入图片说明 My talend job is working perfectly now,but i would like to induce some basic quality validation checks and put them in place to capture the error right away without any hassle.So inorder for that i am going to schedule the job to run hourly and if there is some failure due to disk space,FTP connection failure issues,errors due to file parsing name(by splitting the name i will load into db) -So if i run into java IOException****nullpointerexception or something like that.How do i capture the error from console onto the log file in the folder from the talend job which keeps running in the background.

This is the code i am using to write the console output to an file.however i cannot capture the erraneous cases,please advise how to do that:

java.io.File file = new java.io.File("C:/Users/hsivakumar/Desktop/tests/output.txt");

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

//java.io.File outputFileErr = new java.io.File("C:/Users/hsivakumar/Desktop/tests/outputerr.txt");

System.setOut(ps);

System.setErr(outputFileErr);

I am getting an error when using setErr

You don't need to code in Talend to catch and log Exception. Just drop a tLogCatcher and link its output to a file component.

在此处输入图片说明

The tLogCatcher will catch the Exception and populate several fields.

在此处输入图片说明

The tFileOutputDelimited will create your log file.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM