Logging log in a file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
girishoak
Participant
Posts: 65
Joined: Wed Oct 29, 2003 3:54 am

Logging log in a file

Post by girishoak »

Hi,

Can we get log recorded by job in a file. for example. whenever we do extraction, job logs something like 'n number of rows read' Can we have the same log in a flat file.

If yes, how?

Thanks in advance.

Girish Oak
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

Post by spracht »

You can do it manually in Director by chosing Project -> Print and checking the 'Print to file' option. DSGetLogSummary and DSGetLogEntry look like you could do something similar. I am furthermore quite sure that, I think it was Kim, posted code that did exactly that.
If you are only interested in processing statistics, i.e. how many rows have gone up and down the active stages' links, you can try something like the following in an after job subroutine:


Code: Select all

INCLUDE DSINCLUDE JOBCONTROL.H  

jobname=DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
invocation=DSGetJobInfo(DSJ.ME, DSJ.JOBINVOCATIONID)
email='giris@hoak.com'

if len(invocation)>0 then
	logfile=jobname:'_':invocation:'_':ereplace(oconv(date(), "D-YMD[4,2,2]"),'-',''):'.log'
end else
	logfile=jobname:'_':ereplace(oconv(date(), "D-YMD[4,2,2]"),'-',''):'.log'
end
subject=ereplace(logfile,'_','')

OpenSeq logfile To log Then WeofSeq log
stages=DSGetJobInfo(DSJ.ME, DSJ.STAGELIST)
for i=1 to DCount(stages,',')
	WriteSeq char(10) To log Then w=@True 
	links=DSGetStageInfo(DSJ.ME, Field(stages,',',i), DSJ.LINKLIST)
	for j=1 to DCount(links,',')
 		rows=DSGetLinkInfo(DSJ.ME, Field(stages,',',i), Field(links,',',j), DSJ.LINKROWCOUNT)
		WriteSeq fmt(Field(stages,',',i):'.':Field(links,',',j):': ',"70' 'L"):fmt(rows, "10' 'R") To log Then w=@True 
	next j
next i

InputArg="cat ":logfile:" |mailx -s '":subject:"' ":email
Call DSExecute("UNIX", InputArg, Output, SystemReturnCode)

ErrorCode = 0      ;* set this to non-zero to stop the stage/job
Kind Regards
Stephan
Amos.Rosmarin
Premium Member
Premium Member
Posts: 385
Joined: Tue Oct 07, 2003 4:55 am

Post by Amos.Rosmarin »

This issue has been discoused before. There is no built-in DS process to get and analyze statistics from your ETL process but you have several options:

1. Buy MetaStage (but don't forget reminding your Ascential rep to spare me some of the commission).

2. Write yourself some routines that uses the DS routines and macros such as DSGetJobInfo and DSGetLinkInfo.

3. Do the same from outside DS by using dsjob -log.....

4. There is a new option availble in DS7 : dsjob -report it gives you all the statistics of a job including is xml format.


HTH,
Amos
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You could create a DataStage job to do it!
Column names in the log are found by executing LIST DICT RT_LOG at the command level. Your job will need to determine the job number, to form the name of the actual log table (RT_LOGnn).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply