Here是关于 apache commons logging
的用户指南,但它没有关于占位符的示例。 Slf4j可以替换{}
根据日志级别,例如它不调用 toString
并且不替换 {}
未启用日志级别时。 apache commons logging 是否支持此功能?
最佳答案
不,它不支持占位符。如果您需要动态生成字符串(由于内存分配导致的昂贵操作),请将日志记录调用包装在一个条件中:
Performance is often a logging concern. By examining the appropriate property, a component can avoid expensive operations (producing information to be logged).
For example,
if (log.isDebugEnabled()) { ... do something expensive ... log.debug(theResult); }
— [https://commons.apache.org/proper/commons-logging/apidocs/org/apache/commons/logging/Log.html]
关于java - apache commons 日志记录是否支持占位符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40901546/