Page 1 of 3

Extract of log file using DSGetLogEntry not working

Posted: Mon Nov 18, 2013 8:52 am
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.

Posted: Mon Nov 18, 2013 9:01 am
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.

Posted: Mon Nov 18, 2013 9:24 am
by DSRajesh
craig,

i am trying to using dsgetnewestlogid() ...

Posted: Mon Nov 18, 2013 11:01 am
by chulett
And? I'm aware of that.

Posted: Mon Nov 18, 2013 10:39 pm
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.

Posted: Tue Nov 19, 2013 12:47 am
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.

Posted: Tue Nov 19, 2013 4:56 am
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

Posted: Tue Nov 19, 2013 12:10 pm
by DSRajesh
could any one please suggest on this

Posted: Tue Nov 19, 2013 12:39 pm
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.

Posted: Tue Nov 19, 2013 9:15 pm
by DSRajesh
Craig,

I am unable to see full content as my premium expired ....could you please provide code can be used and helpful

Posted: Wed Nov 20, 2013 2:55 am
by ray.wurlod
Try putting a space between "Step" and "-1".

Posted: Wed Nov 20, 2013 4:01 am
by DSRajesh
Ray,

already there is space between step and -1

Posted: Wed Nov 20, 2013 6:46 am
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

Posted: Wed Nov 20, 2013 8:17 am
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.

Posted: Wed Nov 20, 2013 11:52 am
by DSRajesh
I am Unable to see your complete post as my membership expired.
Please post the DSLogInfo content