Six Stars

Capture System.out.println output in tesb.log

In my TOS ESB tRestRequest/ tRestResponse job, I have put in a few debug statements using System.out.println(). These show up when I am running the Runtime container using ./trun

 

However, when I start the Runtime container using ./start, these logs do not appear and neither are they logged in the <RunTimeContainer>/log/tesb.log file

 

How can I capture that information? Please help. This has been driving me crazy for the past few days.

 

Thank you.

  • ESB
17 REPLIES
Seven Stars

Re: Capture System.out.println output in tesb.log

Hi,

 

Could you try with log.info() ?

 

Eric

Six Stars

Re: Capture System.out.println output in tesb.log

Umm, Do I need to import any libraries? log.info() gives me.. Any example will be helpful. Or any other way in which I can capture the console details in tesb.log

log cannot be resolved
Seven Stars

Re: Capture System.out.println output in tesb.log

In a tJavaRow, I just enter:

 log.info("This is a test");

 

In your job code, don't you see these java lines:

if (!"".equals(log4jLevel)) {
if ("trace".equalsIgnoreCase(log4jLevel)) {
log.setLevel(org.apache.log4j.Level.TRACE);
} else if ("debug".equalsIgnoreCase(log4jLevel)) {
log.setLevel(org.apache.log4j.Level.DEBUG);

...

 

Eric

Six Stars

Re: Capture System.out.println output in tesb.log

So, what do I need to initialize "log" in my code?
Seven Stars

Re: Capture System.out.println output in tesb.log

I don't know... If I create a job without any component, I already have this code piece...

Six Stars

Re: Capture System.out.println output in tesb.log

wow, for me, it says "log cannot be resolved". Can you check someother component in your design and see where its instantiated please?
Eleven Stars

Re: Capture System.out.println output in tesb.log

What version of Talend are you using @plumberg? If you go to your "Code" tab which shows you the autogenerated Java code for your job, you should see some code that looks like this....

 

//GetFileDetails.class is the name of the job 
private static org.apache.log4j.Logger log = org.apache.log4j.Logger .getLogger(GetFileDetails.class);

My suspicion is that you are not using v6. 

 

 

Rilhia Solutions
Eleven Stars

Re: Capture System.out.println output in tesb.log

You can potentially get around this (I've not tried this since I do not have a version without this on my current machine) by adding the relevant Jar using a tLibraryLoad and using the following code....

org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("MyLog");

I'd be interested to see if this works. As I said, I would have tried this myself but the version I am using has this.

 

Another possibility could be that this is functionality left out of the open source edition.

Rilhia Solutions
Six Stars

Re: Capture System.out.println output in tesb.log

@rhall_2_0:

I am using TESB Open Studio V 6.3.1. Is that a problem?
Six Stars

Re: Capture System.out.println output in tesb.log

I think you are right, its not in Open source edition.
Six Stars

Re: Capture System.out.println output in tesb.log

So what are my alternatives to capture console logs? Lots show up when doing ./trun. But nothing when doing ./start.

Seven Stars

Re: Capture System.out.println output in tesb.log

It is a poor solution but with a TlogRow, you can get logs in Karaf...

Six Stars

Re: Capture System.out.println output in tesb.log

I will try that.
Employee

Re: Capture System.out.println output in tesb.log

You might see the sysouts in wrapper.log if you start as a Service

Six Stars

Re: Capture System.out.println output in tesb.log

Hmm, this is interesting. Can you share more details on how to get the wrapper and service setup? is there anything on Talend Documentation?
Eleven Stars

Re: Capture System.out.println output in tesb.log

Six Stars

Re: Capture System.out.println output in tesb.log

Thank you so much. I will try to implement and see if this solves my problem!