如何通过日志/输出文件捕获空指针异常、FTP连接问题的Talend作业。

huangapple go评论68阅读模式
英文:

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

问题

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

注: 上述代码是用于将控制台输出写入文件的,但无法捕获错误情况。

英文:

如何通过日志/输出文件捕获空指针异常、FTP连接问题的Talend作业。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

答案1

得分: 1

你不需要在Talend中编写代码来捕获和记录异常。只需拖放一个tLogCatcher并将其输出链接到文件组件。

tLogCatcher将捕获异常并填充几个字段。

tFileOutputDelimited将创建您的日志文件。

英文:

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.

如何通过日志/输出文件捕获空指针异常、FTP连接问题的Talend作业。

The tLogCatcher will catch the Exception and populate several fields.

如何通过日志/输出文件捕获空指针异常、FTP连接问题的Talend作业。

The tFileOutputDelimited will create your log file.

如何通过日志/输出文件捕获空指针异常、FTP连接问题的Talend作业。

huangapple
  • 本文由 发表于 2020年10月13日 15:26:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/64330493.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定