Log to file
Moderators: chulett, rschirm, roy
Log to file
Hi All,
How do we dump the latest log of a job to a text file? there's is a requirement where we need to send the log to client in case of a failure. Due to time constaint, i was able to browse a few of the posts on this topic, but didn't quite get it.
Would prefer if somebody can guide using BASIC/server job ?
How do we dump the latest log of a job to a text file? there's is a requirement where we need to send the log to client in case of a failure. Due to time constaint, i was able to browse a few of the posts on this topic, but didn't quite get it.
Would prefer if somebody can guide using BASIC/server job ?
Rgds,
MB
MB
i had tried the same some months ago, that's here:
viewtopic.php?t=141047
I believe that will help you more
viewtopic.php?t=141047
I believe that will help you more
pandeeswaran
Code: Select all
# maillog.sh #
#Author:Pandeeswaran #
#This is used to retrieve the warnings and fatals alone in the recent run #
START_ID=`/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servername -user username -password pwd -logsum -type STARTED Projectname Jobname| nawk 'ORS=(FNR%2)?FS:RS' | grep Starting | tail -1 | awk '{print $1 }'`
WARN_ID=`/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server Servername -user username -password pwd -logsum -type WARNING Projectname Jobname| grep WARNING | awk '{print $1 }'`
FATAL_ID=`/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server Servername -user username -password pwd -logsum -type FATAL Projectname Jobname| grep FATAL | awk '{print $1 }'`
echo "WARNINGS AND FATALS:" > /path/log.txt
ALL_ID=`echo "${WARN_ID} ${FATAL_ID}"`
for ID in ${ALL_ID}
do
if [[ "${ID}" -gt "${START_ID}" ]]
then
ALL_DTL=`/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server Servername -user username -password pwd -logdetail Projectname Jobname ${ID}`
echo ${ALL_DTL}\n >> /path/log.txt
echo "\n" >>/path/log.txt
fi
done
(cat /path/log.txt)|mailx -s "find the fatals and warnings" "mailid"
exit 0
Last edited by pandeesh on Wed Feb 15, 2012 4:52 am, edited 2 times in total.
pandeeswaran
I believe you have BASIC guide.Everything is documented over there.
You can check
You can check
Code: Select all
DSJ.LOGSTARTED
pandeeswaran
LOGSTARTED and LOGANY in DSNewestLogId is yielding the same results, which is the last event id for latest run
i am using code(this is just a draft version):
job = pJobName
log_file = pJobLogFile
control = DSJobName
Call DSLogInfo("job name is ":job,control)
Call DSLogInfo("Output log file is ":log_file,control)
hJob = DSAttachJob(job,DSJ.ERRFATAL)
Call DSLogInfo("job attached now",control)
st_id= DSGetNewestLogId(hJob,DSJ.LOGSTARTED)
Call DSLogInfo("Start id is: ":st_id, control)
end_id= DSGetNewestLogId(hJob,DSJ.LOGANY)
Call DSLogInfo("End id is: ":end_id, control)
please let me know if i am missing anything here.
i am using code(this is just a draft version):
job = pJobName
log_file = pJobLogFile
control = DSJobName
Call DSLogInfo("job name is ":job,control)
Call DSLogInfo("Output log file is ":log_file,control)
hJob = DSAttachJob(job,DSJ.ERRFATAL)
Call DSLogInfo("job attached now",control)
st_id= DSGetNewestLogId(hJob,DSJ.LOGSTARTED)
Call DSLogInfo("Start id is: ":st_id, control)
end_id= DSGetNewestLogId(hJob,DSJ.LOGANY)
Call DSLogInfo("End id is: ":end_id, control)
please let me know if i am missing anything here.
Rgds,
MB
MB
I think you are facing the same issue whichever i faced.
Please reread my older post and finally you can find the suggestion provided by evee1:
But i din't face any issues in the unix script i have posted(Because of this only, i went for unix solution at that time )
Please reread my older post and finally you can find the suggestion provided by evee1:
Code: Select all
However, when I changed the routine to do the following instead:
Code:
NewestStartId = DSGetNewestLogId(DSJ.ME, DSJ.LOGSTARTED)
NewestLogId = DSGetNewestLogId(DSJ.ME, DSJ.LOGANY)
the routine is able to locate the starting event correctly.
pandeeswaran
That's what the problem is. If you can have a quick look at the sample code above, i used a separate job handle for that job.
But the problem here is LOGSTARTED & LOGANY are returning same event id(last event id for latest run), instead of last start event id and last event id of that particular job, respectively.
But the problem here is LOGSTARTED & LOGANY are returning same event id(last event id for latest run), instead of last start event id and last event id of that particular job, respectively.
Rgds,
MB
MB