slf4j icon indicating copy to clipboard operation
slf4j copied to clipboard

Platform Logging bridge should use MessageFormat but it's using String.format

Open miyakawataku opened this issue 3 years ago • 1 comments

java.lang.System.Logger.log is specified to accept the message format of MessageFormat. However, the current SLF4JPlatformLogger implementation uses String.format instead of MessageFormat. As a result, the current implementation cannot format the message correctly.

Expected and actual behavior

LoggerFinder finder = System.LoggerFinder.getLoggerFinder();
Logger systemLogger = finder.getLogger("smoke", null);
systemLogger.log(Level.INFO, "hello {0}", "world");

Expected output:

INFO smoke - hello world

Actual output:

INFO smoke - hello {0}

What this change does

This change replaces use of String.format by MessageFormat.format to comply the spec of Platform Logging.

miyakawataku avatar Dec 22 '21 13:12 miyakawataku

Filed JIRA ticket SLF4J-529.

miyakawataku avatar Dec 22 '21 13:12 miyakawataku

I ran into this @ceki and had to switch to formatting prior to logging. Please consider fixing this mistake.

ben-manes avatar Apr 06 '23 09:04 ben-manes

Just checking to see if this PR is not yet merged for a reason or just busy?

rob-bygrave avatar Jul 16 '23 21:07 rob-bygrave

I wonder about this one as well. It's a little inconvenient to deal with at the moment.

SentryMan avatar Aug 08 '23 03:08 SentryMan