lazy
Coerces a lambda expression or method reference to return a lazily evaluated logging argument. Pass in a compatible, no-argument, lambda expression or method reference to have it evaluated only when logging will actually occur.
logger.atFine().log("value=%s", lazy(() -> doExpensive()));
logger.atWarning().atMostEvery(5, MINUTES).log("value=%s", lazy(stats::create));
Content copied to clipboard
Note also that it is almost never suitable to make a toString() call "lazy" using this mechanism and, in general, explicitly calling toString() on arguments which are being logged is an error as it precludes the ability to log an argument structurally.