Page 1 of 1
Archive Datastage Job Logs
Posted: Mon Sep 13, 2010 12:49 pm
by victor236
Hi....
I am trying to archive the job log after every run, i need to save the full detail log in a flat file.
I am able to save the status of the job and runtime but i need the whole log even if it ran with OK, Warn or Aborted. Is there any way to get the log.
I am using 7.5.2 Version on Windows platform.
Any suggestions would be very helpful...
Thanks in advance... :D
Posted: Mon Sep 13, 2010 2:52 pm
by ray.wurlod
From the operating system (perhaps through ExecDOS) you can redirect the output of dsjob -logsum command. Or you can create your own routine using functions from the DataStage API to interrogate the log.
Posted: Mon Sep 13, 2010 3:33 pm
by kduke
You need to parameterize the job number to use a UV stage to read RT_LOG#pJobNumber#. You could easily source this hashed file and write it to any table necessary.
Posted: Tue Sep 14, 2010 9:58 am
by victor236
Hi Ray & Duke..
Thanks for the response....
Duke -
Can you tell me something more about the UV stage and how can i read the log... What are the columns to specified to retrieve the log...
I tried with couple of dummy columns where I can get date occurred and event ... but i am not able to retrieve the first 2 records i.e., Starting job parameters and Environment variable settings.
Thanks ....
Posted: Tue Sep 14, 2010 4:26 pm
by kduke
You can import the metadata using a Q-pointer otherwise you have to build it manually. At TCL you can LIST.DICT RT_LOG47. You need to do a search on how to use TCL commands. There is a video on how to install EtlStats where I do some TCL commands. It may help.
Posted: Tue Sep 14, 2010 4:59 pm
by ray.wurlod
You might like to adapt the following example.
Code: Select all
SUBROUTINE ArchiveJobLog(InputValue, ErrorCode)
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
$INCLUDE UNIVERSE.INCLUDE FILEINFO.H
DEFFUN OpenSequentialFile(FilePath,OpenMode,WriteMode,LogMode) CALLING "DSU.OpenSequentialFile"
ErrorCode = 0
* InputValue contains pathname of log file.
hFile = OpenSequentialFile(InputValue, "W", "O", "Y")
If FileInfo(hFile, FINFO$IS.FILEVAR)
Then
JobStartTimestamp = DSGetJobInfo(DSJ.ME, DSJ.JOBSTARTTIMESTAMP)
NewestStartId = DSGetLogInfo(DSJ.ME, DSJ.LOGSTARTED)
NewestLogId = DSGetLogInfo(DSJ.ME, DSJ.LOGANY)
InterimStatus = DSGetJobInfo(DSJ.ME, DSJ.JOBINTERIMSTATUS)
WriteCount = 0
For EventId = NewestStartId To NewestLogId
LogEntry = DSGetLogEntry(DSJ.ME, EventId)
TimeStamp = Field(LogEntry, "\", 1, 1)
UserInformation = Field(LogEntry, "\", 2, 1)
EventType = Field(LogEntry, "\", 3, 1)
EventMessage = Field(LogEntry, "\", 4, 99999)
WriteSeq LogEntry To hFile Then WriteCount += 1
Next EventId
InfoMsg = WriteCount : " lines written to archive file."
Call DSLogInfo(InfoMsg, "ArchiveJobLog")
End
Else
ErrMsg = "Unable to open " : Quote(InputFile)
Call DSLogWarn(ErrMsg, "ArchiveJobLog")
ErrorCode = 1
End
RETURN