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?
The simpler, user tWarn from anywhere in your job to send messages and tLogCatcher to catch them and write to the desired logfile:
Hope this helps
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")
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)
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?
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.
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
How to use context variable to display 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.
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.