Class LogParser
java.lang.Object
org.apache.juneau.microservice.resources.LogParser
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<LogParser.Entry>,Iterator<LogParser.Entry>
public class LogParser
extends Object
implements Iterable<LogParser.Entry>, Iterator<LogParser.Entry>, Closeable
Utility class for reading log files.
Provides the capability of returning splices of log files based on dates and filtering based on thread and logger names.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents a single line from the log file. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
LogParser
public LogParser(LogEntryFormatter formatter, File f, Date start, Date end, String thread, String[] loggers, String[] severity) throws IOException Constructor.- Parameters:
formatter- The log entry formatter.f- The log file.start- Don't return rows before this date. Ifnull , start from the beginning of the file.end- Don't return rows after this date. Ifnull , go to the end of the file.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.- Throws:
IOException- Thrown by underlying stream.
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
hasNext
- Specified by:
hasNextin interfaceIterator<LogParser.Entry>
-
iterator
- Specified by:
iteratorin interfaceIterable<LogParser.Entry>
-
next
- Specified by:
nextin interfaceIterator<LogParser.Entry>
-
remove
- Specified by:
removein interfaceIterator<LogParser.Entry>
-
writeTo
Serializes the contents of the parsed log file to the specified writer and then closes the underlying reader.- Parameters:
w- The writer to write the log file to.- Throws:
IOException- Thrown by underlying stream.
-