on-internet
← Community

kotlin logging with lambda parameters

Stack Overflow ·

In log4j2 we have a handy feature which is described as // Java-8 style optimization: no need to explicitly check the log level: // the lambda expression is not evaluated if the TRACE level is not enabled logger.trace("Some long-running operation returned {}", () -> expensiveOperation()); my attempt to use this in kotlin log.debug("random {}", { UUID.randomUUID() }) which will print random Function0<java.util.UUID> How do we use lambda argument logging with kotlin? Or how do we explicitly tell kotlin what method to call?

Comments

Sign in or sign up to comment and upvote.

No comments yet.