is Enabled
Returns true if logging is enabled at the level implied for this API, according to the current logger backend. For example:
if (logger.atFine().isEnabled()) {
// Do non-trivial argument processing
logger.atFine().log("Message: %s", value);
}
Content copied to clipboard
Note that if logging is enabled for a log level, it does not always follow that the log statement will definitely be written to the backend (due to the effects of other methods in the fluent chain), but if this method returns false then it can safely be assumed that no logging will occur.
This method is unaffected by additional methods in the fluent chain and should only ever be invoked immediately after the level selector method. In other words, the expression:
logger.atFine().every(100).isEnabled()Content copied to clipboard
logger.atFine().isEnabled()Content copied to clipboard
Implementation Note
By avoiding passing a separateLevel at runtime to determine "loggability", this API makes it easier to coerce bytecode optimizers into doing "dead code" removal on sections guarded by this method. If a proxy logger class is supplied for which:
logger.atFine()Content copied to clipboard
isEnabled() always returns false), it becomes simple for bytecode analysis to determine that: logger.atFine().isEnabled()Content copied to clipboard
false .