Formatting floating point numbers in SLF4J

A somewhat ugly solution that incurs the creation of a temporary object could be this

public class DelayedFormatter {
    public static Object format(String format, Object... args) {
        return new Object() {
            @Override
            public String toString() {
                return String.format(format, args);
            }
        };
    }
}

and then

import static DelayedFormatter.format;
...
logger.debug("v = {}", format("%.03f", v));

I am assuming that you're referring to SLF4J's convention of expanding parameters, e.g.:

float f;
...
logger.debug("My number is {}", f);

So, the answer is no. As of SLF4J 1.7.7, what you're asking to do is impossible as SLF4J's expansion algorithm doesn't allow for custom renderers (such as the one available via Log4J).

Seems worthy of a feature request, though.

EDIT:

Well, {} is "only supported" for performance considerations, current formatting implementation outperforms String.format() at 10 times. http://www.slf4j.org/faq.html#logging_performance so it's unlikely to change

(source)