Orders log records by level, thrown, sequence, and time.
This comparator orders LogRecords by how severely each is attributed to
failures in a program. The primary ordering is determined by the use of the
logging API throughout a program by specifying a level to each log message.
The secondary ordering is determined at runtime by the type of errors and
exceptions generated by the program. The remaining ordering assumes that
older log records are less severe than newer log records.
The following LogRecord properties determine severity ordering:
- The natural comparison of the LogRecord
level.
- The expected recovery order of thrown
property of a LogRecord and its cause chain. This ordering is derived from
the JLS 11.1.1. The Kinds of Exceptions and JLS 11.5 The Exception Hierarchy.
This is performed by finding the
throwable that best describes the entire cause chain. Once a specific
throwable of each chain is identified it is then ranked lowest to highest by
the following rules:
- All LogRecords with a
Throwable
defined as
"normal occurrence
".
- All LogRecords that do not have a thrown object.
- All checked exceptions. This is any class that is assignable to the
java.lang.Throwable
class and is not a
java.lang.RuntimeException
or a java.lang.Error
.
- All unchecked exceptions. This is all
java.lang.RuntimeException
objects.
- All errors that indicate a serious problem. This is all
java.lang.Error
objects.
- The natural comparison of the LogRecord
sequence.
- The natural comparison of the LogRecord
millis.