Archive Datastage Job Logs

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
victor236
Participant
Posts: 8
Joined: Thu Aug 12, 2010 10:37 am

Archive Datastage Job Logs

Post 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. 8)

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.
:idea:
I am using 7.5.2 Version on Windows platform. :wink:

Any suggestions would be very helpful...
Thanks in advance... :D
Victor
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post 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.
Mamu Kim
victor236
Participant
Posts: 8
Joined: Thu Aug 12, 2010 10:37 am

Post 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 ....
Victor
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post 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.
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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
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