[slf4j-dev] [JIRA] Updates for SLF4J-371: Support the lambda expression in the Logger

QOS.CH (JIRA) noreply-jira at qos.ch
Fri Dec 24 22:24:00 CET 2021


SLF4J / SLF4J-371 [Resolved]
Support the lambda expression in the Logger

==============================

Here's what changed in this issue in the last few minutes.

There is 1 comment.

View or comment on issue using this link
https://jira.qos.ch/browse/SLF4J-371

==============================
 1 comment
------------------------------

Eric Kolotyluk on 24/Dec/21 10:08 PM
Please support log4j2 style lambda expressions...

While playing with fluent in 2.0.0-alpha5

 
{code:java}
Callable task = () -> {System.out.println("task evaluated"); return "called";};
logger.atDebug().log("Lazy logging {}", task.call());
{code}
At log level "debug" it prints

 
{code:java}
task evaluated
15:39:38.061 [main] DEBUG net.kolotyluk.net.LagTests - Lazy logging called
{code}
but at log level "info" it still prints

 
{code:java}
task evaluated
{code}
Also, IMHO, fluent log statements are ugly. Using lambdas,

 

 
{code:java}
logger.debug(() -> { ... }){code}
 

would give me 90% of what I want, whereas
{code:java}
logger.debug("format {} ... {}", () -> {...}, () -> {...})
{code}
is just gravy.


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)



More information about the slf4j-dev mailing list