[slf4j-dev] Add Supplier args methods for Logger on java 8.

JICHUN LIU jliu666 at hotmail.com
Fri Apr 19 15:55:30 CEST 2019


Hello.

The java.util.function.Supplier is supported from Java 8.

Some new methods like:


public void debug(String format, Supplier<Object> argument);

public void debug(String format, Supplier<Object>... arguments);

may add to org.slf4j.Logger.

Lazy computing improves performance.

Old:

log.info("INFO a {} b {}",JsonUtil.ObjectToJson(instance),"success");

New:


log.info("INFO a {} b {}",()->JsonUtil.ObjectToJson(instance),"success");

The new one with better performance because the ObjectToJson called only on the info level or high.

I found slf4j support jdk version older the 8. Maybe we can create a new module for JDK 8. Supplier on slf4j is really an exciting feature.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-dev/attachments/20190419/c7c9ae2c/attachment.html>


More information about the slf4j-dev mailing list