Page 1 of 1

Logging log in a file

Posted: Thu Oct 30, 2003 6:29 am
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

Posted: Thu Oct 30, 2003 7:03 am
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

Posted: Thu Oct 30, 2003 11:10 am
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

Posted: Thu Oct 30, 2003 3:07 pm
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).