LogAppender class abstract
One output of the logging system: it receives every log record that passes the logger levels and writes it somewhere.
The starter's outputs are appenders too: the console
(ConsoleAppender), the in-memory buffer (LogBuffer) and the log
file (FileAppender). Extend this class when records must also go
somewhere else, such as a crash reporter, a remote log service or a
database; implement write, and set threshold to keep only the
important records. Add it with LoggingSystem.addAppender. An
appender that throws does not stop the others.
// Errors also go to the crash reporter, with their stack trace.
class CrashReportAppender extends LogAppender {
CrashReportAppender() : super(threshold: SpringLogLevel.error);
@override
void write(SpringLogRecord record) =>
crashReporter.log(record.message, record.error, record.stackTrace);
}
LoggingSystem.instance.addAppender(CrashReportAppender());
Spring (Java): a Logback Appender, usually an AppenderBase
subclass declared in logback-spring.xml. Here it is added in code.
Constructors
- LogAppender({SpringLogLevel threshold = SpringLogLevel.trace})
-
An appender that writes records of
thresholdand above (every level by default).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- threshold ↔ SpringLogLevel
-
The lowest level this appender writes, checked after the logger
levels; SpringLogLevel.off writes nothing.
getter/setter pair
Methods
-
append(
SpringLogRecord record) → void - Called by the logging system for each record: passes it to write when it is at or above threshold, and drops it otherwise.
-
close(
) → void -
Releases what the appender holds, such as an open file. Called by
LoggingSystem.removeAppender; does nothing by default. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
SpringLogRecord record) → void -
Writes
recordto this output. Implement it in a subclass; the record has already passed threshold. It runs synchronously on the logging call, so slow work (a network call) should be queued.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited