Six Stars

Customised Message

Hi,

I want to prepare a log with with my customised message like Job started at <sys date time>, File reading starts at <sys date time>.......... till end with execution ends at <sys date time>

 

How we can achieve it using talend?

  • Data Integration
  • Exchange components
  • Talend Integration Cloud
Tags (1)
9 REPLIES
Nine Stars TRF
Nine Stars

Re: Customised Message

Hi,

 

The simpler, user tWarn from anywhere in your job to send messages and tLogCatcher to catch them and write to the desired logfile:

tLogCatcher.PNG

Hope this helps


TRF
Six Stars

Re: Customised Message

Can I add system date and time with tWarn info message?

Nine Stars TRF
Nine Stars

Re: Customised Message

If you mean is the message text, you can do something like

"Here is the current date and time "+TalendDate.getDate("yyyy-MM-dd HH:mm:ss")

TRF
Eleven Stars

Re: Customised Message

You shouldn't need to go to any extra lengths to get a time and date when using a tLogCatcher (as shown by TRF). The data will be there for you. Take a look at this tutorial on the AMC (https://www.rilhia.com/tutorials/talend-activity-monitoring-console-amc)

Rilhia Solutions
Six Stars

Re: Customised Message

Hi,

 

Thanks for the reply. If I want to log each step of my job and wants to make reusable logging component with tWarn -> tCatcher -> tLogRows. How we can dynamically print message into logger like reading files, join tables using tmap, filtering rows etc etc? 

Nine Stars TRF
Nine Stars

Re: Customised Message

The subjob I give is a minimal but typical example. You can transform it to do what you expect.

TRF
Six Stars

Re: Customised Message

Hi,

 

I know, I am asking lot of questions but please bear with me.

 

I tried to create a job that display log into console and store them in file. PFA logging job.

 logger .jpg

 

 

 

I added above job into another job and set some context variables to display message based on processing steps. But I am not able to set context variable as the context variable buttons are all disabled. PFA

componenet_view.jpg

 

How to use context variable to display customised  message?

 

Thanks...

 

Nine Stars TRF
Nine Stars

Re: Customised Message

You do not have to link tWarn to tLogCatcher cause tLogCatcher automatically wake up when a message arrive.

Also, you do have to place the logging sequence in a seperate job (it should work but it is not the idea).

Just place a subjob for the logging sequence (using a joblet if you use the enterprise edition) and send the desired message when you need using tWarn with the appropriate message.

If you want to to change the logging file for any reason between 2 sequences of the job, just overwrite the context (or the global) variable which contains the full pathname of the logfile you want to use.


TRF
Eleven Stars

Re: Customised Message

I'm not sure if you have experienced this @TRF but changing the logging file/db credentials within the job for the AMC can be a bit of a pain if you want to drive it from context variables. Essentially the problem is caused by the fact that the logging starts before the context variables are actually set within the job. Madness. 

There are a couple of ways around this. The first (and easiest) is to put your job in a wrapper job which has the sole purpose of passing the context variables (for the AMC) to the job you wish to use the AMC with. This wrapper job will not be able to use the AMC to it fullest, but the child job (and jobs within that) will be able to get full AMC logging.

Another way of dealing with this is to set up the logging, stats, etc components to send the data to tHash components (store the data in memory). Then you can have a tPostJob which will always run (no matter what Java errors, etc happen) which merely outputs what the tHash components hold regarding logging. This removes the timing issue with passing AMC credentials to the job since it all happens at the end. 

Rilhia Solutions