Flogger:�A Fluent Java Logging API
Use it in Gerrit?
(Edwin Kempin)
Outline
The state of logging in Gerrit
Logging with SLF4J
log.error("Error in {} {}", req.getMethod(), uri, err);��Problems:
Flogger, a fluent logging API
Flogger, a fluent logging API
SLF4J:�log.error("Error in {} {}", req.getMethod(), uri, err);
Flogger:�logger.atSevere()� .withCause(err)� .log("Error in %s %s", req.getMethod(), uri);��⇒ More readable, less prone to confusion about parameter ordering,� more discoverable in IDE
Flogger: Initialization of Logger
SLF4J:�private static final Logger log = � LoggerFactory.getLogger(PublicKeyChecker.class);
Flogger:�private static final FluentLogger logger = � FluentLogger.forEnclosingClass();�
Flogger Benefits
Flogger Performance
Logging at disabled levels is effectively free:�(https://google.github.io/flogger/benefits#cheap-disabled-logging)
“The simple log.info(String, Object...) approach to logging is concise at the source code level, but can introduce surprising cost in bytecode. Vararg methods require a new Object[] to be allocated and filled before the method can be invoked. Additionally any fundamental types passed in must be auto-boxed. This all costs additional bytecode and latency at the call site and is particularly unfortunate if the log statement isn’t actually enabled.”
Flogger Extensibility
Migration Cost
Request Tracing
⇒ All this is possible to implement when we use Flogger.
Questions & Feedback
Flogger Resources