public final class LogParser extends Object implements Iterable<LogParser.Entry>, Iterator<LogParser.Entry>, Closeable
Provides the capability of returning splices of log files based on dates and filtering based on thread and logger names.
| Modifier and Type | Class and Description |
|---|---|
class |
LogParser.Entry
Represents a single line from the log file.
|
| Constructor and Description |
|---|
LogParser(LogEntryFormatter formatter,
File f,
Date start,
Date end,
String thread,
String[] loggers,
String[] severity)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
hasNext() |
Iterator<LogParser.Entry> |
iterator() |
LogParser.Entry |
next() |
void |
remove() |
void |
writeTo(Writer w)
Serializes the contents of the parsed log file to the specified writer and then closes the underlying reader.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorforEachRemainingpublic LogParser(LogEntryFormatter formatter, File f, Date start, Date end, String thread, String[] loggers, String[] severity) throws IOException
formatter - The log entry formatter.f - The log file.start - Don't return rows before this date. If end - Don't return rows after this date. If thread - Only return log entries with this thread name.loggers - Only return log entries produced by these loggers (simple class names).severity - Only return log entries with the specified severity.IOException - Thrown by underlying stream.public boolean hasNext()
hasNext in interface Iterator<LogParser.Entry>public LogParser.Entry next()
next in interface Iterator<LogParser.Entry>public void remove()
remove in interface Iterator<LogParser.Entry>public Iterator<LogParser.Entry> iterator()
iterator in interface Iterable<LogParser.Entry>public void close() throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void writeTo(Writer w) throws IOException
w - The writer to write the log file to.IOException - Thrown by underlying stream.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.