Extract of log file using DSGetLogEntry not working

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Extract of log file using DSGetLogEntry not working

Post by DSRajesh »

Dear All,

I tried to extract the log using below routine. Here i am able to fetch the last row which will have the job status log entry.

Code: Select all

 $INCLUDE DSINCLUDE JOBCONTROL.H 
 JobName = Arg1 
 hJob = DSAttachJob(JobName, DSJ.ERRNONE) 

 LatestStartId = DSGetNewestLogId(hJob, DSJ.LOGSTARTED) 

 LatestLogId = DSGetNewestLogId(hJob, DSJ.LOGANY) 

 For iEventID =  LatestStartId to LatestLogId  Step-1 
    
     vEventDetail<-1> = FIELD(DSGetLogEntry(hJob, iEventID), "", 1)

 next iEventID 

 Mail = DSSendMail("From:hari@removed.com\nTo:hari@removed.com\nServer:removed.com\nSubject:\nBody:Please find the log":vEventDetail ) 


 Ans = Mail

 iIgnore = DSDetachJob(hJob)
I need to fetch all the log entries from job control start to end of job control.

Looking forward for the suggestion which will help in getting the complete log entries for the latest run.
RD
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Putting a real email here probably wasn't something you meant to do, I redacted it. In your shoes I'd start by adding some 'bread crumbs', calls to DSLogInfo() for the values you are fetching to start the debugging process.

Don't forget you are putting everything into a dynamic array which won't present well in its native format. I'd suggest converting the Field Marks in vEventDetail to returns and see if that helps.
Last edited by chulett on Mon Nov 18, 2013 11:02 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

craig,

i am trying to using dsgetnewestlogid() ...
RD
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And? I'm aware of that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Suggest me is there a way i can achieve the above requirement using routine which will get the entire log rather than the latest event id and event detail for that.
RD
prasson_ibm
Premium Member
Premium Member
Posts: 536
Joined: Thu Oct 11, 2007 1:48 am
Location: Bangalore

Post by prasson_ibm »

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 
JobName = FIELD(Arg1,"|",1) 
evtMessage1 = ""
hJob1 = DSAttachJob(JobName, DSJ.ERRNONE) 
jobStart = DSGetJobInfo (hJob1, DSJ.JOBSTARTTIMESTAMP) 
latestID = DSGetNewestLogId(hJob1,DSJ.LOGANY) 

For eventID = latestID To 1 Step -1 

         eventDetail = DSGetLogEntry(hJob1,eventID) 
         evtDate = FIELD(eventDetail,"\",1) 
         evtDate = CHANGE(evtDate,"Date: ","") 
         evtMessage = FIELD(eventDetail,"\",4) 
         evtType = Field(eventDetail,"\",3) 

         If evtDate < jobStart Then Exit 
         
          
         If evtType = "3" Then 
            errFlag = @True 
            evtMessage1 = evtMessage:"~":evtMessage1
         END

Next eventID 
You can change this code according to your requirment.This routine is to log fatal errors.
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Thanks Prasson ,

I am trying to get all the "Info" event type with the below code

Code: Select all

eventDetail = DSGetLogEntry(hJob1,eventID) 
         evtDate = FIELD(eventDetail,"\",1) 
         evtDate = CHANGE(evtDate,"Date: ","") 
         evtMessage = FIELD(eventDetail,"\",4) 
         evtType = Field(eventDetail,"\",3) 

If evtType1 = "1" Then 
           errFlag = @True 
          evtMessage1 = evtMessage:"~":evtMessage1 
                    END 
I am able to getting only the Environment Variables log entry but skipping all the "info" type entries after that.


Please suggest me here
RD
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

could any one please suggest on this
RD
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Already did and stand by my first post on the subject of breadcrumbs. Start by adding in several logging statements so you can see what values are being pulled by the API calls you are making. Can go a long way towards knowing where it is you are going astray.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Craig,

I am unable to see full content as my premium expired ....could you please provide code can be used and helpful
RD
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try putting a space between "Step" and "-1".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Ray,

already there is space between step and -1
RD
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

I am trying to test below routine :

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 
 JobName = Arg1 
 hJob = DSAttachJob(JobName, DSJ.ERRNONE) 
 LogIdList = DSGetLogEventIds(hJob, 0, 'S')
 For iEventID =  LogIdList to LogIdList  Step +1 
   vEventDetail = DSGetLogEntry(hJob, iEventID)
 next iEventID 

Ans = LogIdList

iIgnore = DSDetachJob(hJob)
after run the routine i am getting below output:

TEST #1
*******

Arg1 = JobStgLoad_log

Test completed.

Program "DSU.GetLogforAbortedJobs": Line 9, Nonnumeric data when numeric required. Zero used.
Program "DSU.GetLogforAbortedJobs": Line 9, Nonnumeric data when numeric required. Zero used.
Program "DSU.GetLogforAbortedJobs": Line 9, Nonnumeric data when numeric required. Zero used.

Result = 2013-11-20 01:56:22\chjk\5\Starting Job JobStgLoad_log

I am not able to get the complete log.

Can any one suggest me what is the issue and how to get the complete log
RD
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Breadcrumbs. Where are the DSLogInfo calls? :?

Your for loop is broken. You can't step from X to X where X is a list of event numbers.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

I am Unable to see your complete post as my membership expired.
Please post the DSLogInfo content
RD
Post Reply