为什么 slf4j 字符串格式与 `string.format` 不同
Why is slf4j string format NOT the same as `string.format`
如果您使用 Slf4j 和 log.info("The value is: %s", "a_value")
,您将得到如下输出:The value is: %s
。这与使用 log.info(String.format("The value is: %s", "a_value"))
可能得到的完全不同,更像是:The value is: a_value
.
我真的不需要知道什么是正确的格式,只要 WHY Slf4j 中日志消息的格式是 NOT 与 java.lang.String#format
的 format 相同,这是否仍然是 Java 中的有效理由,什么,10?
正如 SLF4J FAQ 所说,它使用不同的格式,因为它使用的格式的处理速度可以提高 10 倍。
如果您使用 Slf4j 和 log.info("The value is: %s", "a_value")
,您将得到如下输出:The value is: %s
。这与使用 log.info(String.format("The value is: %s", "a_value"))
可能得到的完全不同,更像是:The value is: a_value
.
我真的不需要知道什么是正确的格式,只要 WHY Slf4j 中日志消息的格式是 NOT 与 java.lang.String#format
的 format 相同,这是否仍然是 Java 中的有效理由,什么,10?
正如 SLF4J FAQ 所说,它使用不同的格式,因为它使用的格式的处理速度可以提高 10 倍。