Package com.ibm.websphere.logging.hpel.reader

Provides classes and interfaces for reading log records stored in HPEL format.

See: Description

Package com.ibm.websphere.logging.hpel.reader Description

Provides classes and interfaces for reading log records stored in HPEL format.

HPEL repositories store log and trace content in a binary format which requires an API to read. Individual log and trace records are represented by the RepositoryLogRecord interface. A ServerInstanceLogRecordList is a collection of RepositoryLogRecords from one server process. The RepositoryReader interface provides methods for getting a ServerInstanceLogRecordList.

To read a local HPEL repository, use the RepositoryReaderImpl class to query for a ServerInstanceLogRecordList. Iterate over the ServerInstanceLogRecordList to obtain the contained RepositoryLogRecord instances. Additionally, information related to all log records in the server process is accessible from properties via the ServerInstanceLogRecordList's getHeader method. This information is what would often be displayed in a log file's header.

As an example, to print out all of the records in a log repository located in the directory "repositoryLocation" use the following code:

RepositoryReaderImpl reader = new RepositoryReaderImpl("repositoryLocation");
for(ServerInstanceLogRecordList oneServerList: reader.getLogLists()) {
        oneServerList.getHeader().list(System.out);
        for (RepositoryLogRecord record: oneServerList) {
                System.out.println(record.toString());
        }
}

While iterating through a ServerInstanceLogRecordList, a RepositoryPointer can be obtained from any RepositoryLogRecord. A RepositoryPointer is a pointer to a location in the repository, and can be used in queries to the RepositoryReader to obtain lists of log records that begin with the record immediately following the location denoted by the RepositoryPointer.

The following example illustrates how to search for a particular message in the repository, then use the RepositoryPointer of that log record as a starting point for a query for warning (or more severe) messages.

RepositoryPointer rp = null;
for(RepositoryLogRecord record: reader.getLogListForCurrentServerInstance()) {
        if (record.getMessage().contains("open for e-business")) {
                rp = record.getRepositoryPointer();
        }
}
if (found != null) {
    for (RepositoryLogRecord record: reader.getLogListForServerInstance(rp, Level.WARNING, null)) {
            System.out.println(record.toString());
    }
}

Advanced filtering can be implemented by using RepositoryReaderImpl methods accepting LogRecordFilter or LogRecordHeaderFilter instances as parameters. Queries which make use of the LogRecordHeaderFilter (which can only utilize fields in the RepositoryLogRecordHeader interface) run more efficiently than queries which make use of a LogRecordFilter (which can utilize fields in the entire RepositoryLogRecord interface). A set of predefined filters can be found in the filters package.

The following example illustrates how to list severe log records or messages written to the standard error stream:

LogRecordFilter filter = new LogRecordFilter() {
        public accept(RepositoryLogRecord record) {
                return Level.SEVERE.equals(record.getLevel()) || "SystemErr".equals(record.getLoggerName();
        }
}
for(RepositoryLogRecord record: reader.getLogListForServerInstance((Date)null, filter)) {
        System.out.println(record.toString());
}
Version:
1.1.0
IBM WebSphere Application ServerTM
Release 8.5