wasForced

public abstract boolean wasForced()

Returns whether this log statement should be emitted regardless of its log level or any other properties.

This allows extensions of LogContext or LoggingBackend which implement additional filtering or rate-limiting fluent methods to easily check whether a log statement was forced. Forced log statements should behave exactly as if none of the filtering or rate-limiting occurred, including argument validity checks.

Thus the idiomatic use of wasForced() is:


public API someFilteringMethod(int value) {
  if (wasForced()) {
    return api();
  }
  if (value < 0) {
    throw new IllegalArgumentException("Bad things ...");
  }
  // rest of method...
}

Checking for forced log statements before checking the validity of arguments provides a last-resort means to mitigate cases in which syntactically incorrect log statements are only discovered when they are enabled.