Sample for Read from Systemlogger via ZLogstream



Support for Java SE, EE & ME, JVM, JNI, JDBC, EJB, JFC, JPDA, JAAS,JCE, JAXP, XML and Java API.

Sample for Read from Systemlogger via ZLogstream

Postby SPelzet » Wed Aug 30, 2017 1:10 pm

Hi there,

I'm trying to read (browse) from a Systemlogger with Java. I found the wrapper Class ZLogstream. But there is no sample from IBM how to read with this class.
Can someone give me a sample, which makes things such easier for me?

I found out, that the constructor makes a Connection to the Logstream. But how should I go on..? Thanks in advance.
SPelzet
 
Posts: 3
Joined: Wed Aug 30, 2017 1:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sample for Read from Systemlogger via ZLogstream

Postby Robert Sample » Thu Aug 31, 2017 1:46 am

To make a connection to a logstream, you MUST know the name of it. How do you find the name? Since each and every site can define its own logstream name, you have no choice but to contact your site support group and find out the name of your site's logstream. Then you connect to it, assuming you have appropriate security, and then use the appropriate method to search / browse / whatever the logstream.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Sample for Read from Systemlogger via ZLogstream

Postby SPelzet » Thu Aug 31, 2017 1:19 pm

Well the connection is not the problem. I know the name of the Logstream and yes the connection is successful.

Look at my source


    //get Timestamp
        long unixTimestamp = Instant.now().getEpochSecond();
        RecordReader reader=null;
        int bytesRead =0;
       
        System.out.println("Hallo Welt");
        ZLogstream myStream = new ZLogstream("MTLOGGER.TEST.MTPPS");
        //get Maxium Buffer
        byte[] buffer=new byte[myStream.getMaxBlockLength()];
        myStream.browseStartSearch(false,unixTimestamp);
        bytesRead=myStream.readSearch(unixTimestamp, buffer, 0);       
 


My problem here is that I get no useful information in the Field 'buffer'. In the debugger I values such 0, -15 or something like that. But not printable value, which I can cast to characters.

What should I do here?
SPelzet
 
Posts: 3
Joined: Wed Aug 30, 2017 1:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sample for Read from Systemlogger via ZLogstream

Postby Robert Sample » Thu Aug 31, 2017 6:19 pm

I see in the manual that getMaxBlockLength() is returning an int value -- what happens when you look at the int value?

Here's an article on using Zlogstream (page 15): http://publibz.boulder.ibm.com/epubs/pdf/e0z2n1a1.pdf
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Sample for Read from Systemlogger via ZLogstream

Postby SPelzet » Fri Sep 01, 2017 3:02 pm

Thanks for the link. Very interesting :) But unfourtanely there is only described the write Method. The Browse Feature in this class is fairly new..


Anyway - I refactored my code and now I get an output - but I read only the same record. How could I read the logstream record by record? Not even Block by Block. The documentation is not really helpful....

public class mtbr01 {

    public static void main(String[] args) throws IOException {
       
        try{
        //Log Stream name
        String logName="MTLOGGER.TEST.MTPPS";
        byte[] buffer=new byte[1000000];
        //get Timestamp
        long unixTimestamp = Instant.now().getEpochSecond();
        int bytesRead =0;
        //Open and connect to LogStream (MTLOGGER.TEST.MTPPS)
        ZLogstream zlogger = new ZLogstream(logName);

        zlogger.browseStartSearch(false,unixTimestamp);
       
        for(int i=0;i<10;i++){
        bytesRead=zlogger.readSearch(unixTimestamp, buffer, 0);
        String value = new String(buffer);
        System.out.println("Satz Nummer"+i);
        System.out.println(value);
        }
   
    }
   
    catch(ZLogstreamException EX)
    {
        //Print out messages and return codes from the logger
        System.err.println("System logger error message <" +EX.getMessage() + ">");
        System.err.println("System logger ReturnCode/ReasonCode <"+ EX.getReturnCode() +"/" + EX.getReasonCode() +">");
        System.err.println("System logger resource <" + EX.getLogstreamName() + ">");
        //Print out Java stack trace
        EX.printStackTrace();
        return;                                            
    }
        }

}
SPelzet
 
Posts: 3
Joined: Wed Aug 30, 2017 1:05 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Mainframe Java

 


  • Related topics
    Replies
    Views
    Last post